chrome-extension://regex-tester-pro · live preview

Pattern

/^\+[1-9]\d{1,14}$/

Test string

Updated +41791234567 for Chromium 124

flags: · 1 match · 0.4 ms

All matching happens in your browser. Patterns and test strings never leave the tab.

Regex Guide

Regex for International Phone Numbers (E.164 and friendly formats)

Updated May 2026 8 min read By the Regex Tester Pro team

Quick answer

For E.164 (the canonical international format) use /^\+[1-9]\d{1,14}$/. For human-typed numbers that may include spaces, dashes, and parentheses, normalize first (strip non-digit characters except a leading +) and then validate. Do not try to recognize every country format in one regex.

Phone number validation is harder than email. Country codes vary in length, local formats use different separators, and there is no equivalent to a confirmation email until SMS is involved. The right approach is two passes: a normalize step, then a strict E.164 check.

JavaScript
// Normalize first, then validate against E.164
function toE164(input) {
  // Strip everything except digits and a leading +
  const cleaned = input.replace(/[^\d+]/g, '').replace(/(?!^)\+/g, '');
  return cleaned;
}

const E164 = /^\+[1-9]\d{1,14}$/;

function isValidPhone(input) {
  return E164.test(toE164(input));
}

isValidPhone('+41 79 123 45 67');     // true
isValidPhone('(212) 555-0142');       // false (no country code)
isValidPhone('+1 (212) 555-0142');    // true

E.164: the format you want to store

E.164 is the ITU standard for international phone numbers. Format: + followed by a country code (1 to 3 digits), followed by the subscriber number, total length 7 to 15 digits. No spaces, no dashes, no parentheses. Examples:

If you are storing phone numbers anywhere (database, CRM, SMS provider) E.164 is the only sane representation. Twilio, MessageBird, Vonage, every SMS API expects it. Display formats are a presentation concern; E.164 is the storage format.

The minimal E.164 regex

The pattern /^\+[1-9]\d{1,14}$/ says:

This is intentionally loose. It does not check whether the country code is real, or whether the subscriber number is the right length for that country. That is what libphonenumber is for. The regex is a syntactic guard before you call the heavier validator, not a replacement for it.

Handling human input formats

Real users type numbers with spaces, dashes, parentheses, and inconsistent country code prefixes:

The trick is to normalize first. Strip non-digits except a leading +, replace 00 at the start with +, and require a country code. If the input has no + and no 00 after stripping, you have a national-only number and you need to know the user's country to fill it in.

When the regex is not enough

Three cases force you to use a real phone library:

  1. Country code disambiguation. The number +1 is shared by the US, Canada, and a dozen Caribbean territories. The regex passes them all; only libphonenumber knows the area code mapping.
  2. Length validation per country. Italian mobile numbers are 9 to 10 digits; Swiss mobiles are 9; Chinese mobiles are 11. The regex accepts any 7 to 15 digit body. If you need exact length, use a library.
  3. Number type detection. Mobile vs landline vs toll-free vs premium-rate. Critical for SMS routing and cost control. Libphonenumber returns the type; regex cannot.

For a signup form that just wants to send one verification SMS, the regex plus libphonenumber's parsePhoneNumber() is the standard pairing. Regex blocks obvious typos in real time; the library does the country-aware check on submit.

Same pattern in other languages

The regex itself is portable:

The normalization step changes per language but the logic is the same: strip non-digits except leading +, then test.

Common mistakes

The patterns you will see online but should not copy:

Validate phone numbers without overfitting

Regex Tester Pro gives you live matching, named groups, replacements, and reference cheatsheets in one Chrome popup. Free, private, no signup.

Add to Chrome, free

Frequently asked questions

Should I show users the international format or their local format?
Show local for display ((212) 555-0142), store E.164 (+12125550142). Use libphonenumber to convert between them.
What if the user pastes a phone number with extension?
Strip extensions before validation: split on x or ext, validate the first part, store the extension separately.
Why not allow 16-digit numbers?
E.164 caps at 15 digits including the country code. Anything longer is invalid by the standard.
How do I handle US numbers without a country code?
Pre-fill the country code based on the user's detected locale, but always store the full E.164. Never assume +1.
Is libphonenumber overkill for a small site?
For a contact form, yes. For anything that sends SMS, signs contracts, or charges money, no. The regex alone will route SMS to the wrong country eventually.

More by Peak Productivity

Free developer tools, made for the browser

Privacy-first utilities that run locally. No upload, no signup, no watermark.