★ Identity & contact · regex
Regex for E.164 Phone Number
E.164 is the ITU format for international phone numbers and the one SMS APIs expect: a plus sign, a country code that doesn't start with 0, and at most 15 digits in total, with no spaces or punctuation.
- Runs in your browser
- No signup
Try the e.164 phone number pattern
Read it in plain English (best-effort)
- ^start of a line
- +the character '+'
- [1-9]one character from: 1–9
- [0-9]one character from: 0–9
- {6,14}between 6 and 14 of the previous
- $end of a line
One sample per line works well with the m flag on anchored patterns.
The pattern, piece by piece
/^\+[1-9][0-9]{6,14}$/| Part | What it does |
|---|---|
^\+ | a literal plus sign |
[1-9] | country codes never start with 0 |
[0-9]{6,14} | the rest: 7 to 15 digits in total |
$ | no spaces or punctuation anywhere |
What it accepts and rejects
Every sample below is checked automatically in JavaScript and Python. The tester above is preloaded with all of them, one per line.
| Should match | |
|---|---|
+14155552671 | ✓ |
+919876543210 | ✓ |
+442079460958 | ✓ |
+81312345678 | ✓ |
+61412345678 | ✓ |
+4915112345678 | ✓ |
| Should not match | |
|---|---|
14155552671 | ✗ |
+0123456789 | ✗ |
+1 415 555 2671 | ✗ |
+1234 | ✗ |
+1234567890123456 | ✗ |
+91-9876543210 | ✗ |
Copy it into your code
RE2-safeNo lookarounds or backreferences, so the same pattern works in Go's RE2 engine and in Rust's regex crate.
const e164PhoneRe = /^\+[1-9][0-9]{6,14}$/;
export function isValidE164Phone(value) {
return e164PhoneRe.test(value.trim());
}When not to use regex for this
The regex can't tell whether +91 is followed by a valid Indian number length. libphonenumber knows every country's rules; use it to parse what users type and store the E.164 string it returns.
Questions engineers actually ask
Why no spaces or dashes?
What is the minimum length?
What is catastrophic backtracking?
Sources
Formats were checked on 8 November 2026. Rules change; the official issuer wins if it disagrees.
More identity & contact patterns
- US Phone NumberNANP numbers in common formats, capturing area code, exchange and line.^(?:\+?1[ .-]?)?\(?([2-9][0-9]{2})\)?[ .-]?([2-9][0-9]{2})[ .-]?([0-9]{4})$
- US ZIP CodeFive-digit ZIP codes with an optional ZIP+4 suffix.^[0-9]{5}(?:-[0-9]{4})?$
- Username3–16 characters, starts with a letter, letters, digits and underscores only.^[a-zA-Z][a-zA-Z0-9_]{2,15}$
- Strong Password12+ characters with lowercase, uppercase, a digit and a symbol.^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^A-Za-z0-9]).{12,}$
- Credit Card Number Format16-digit cards in groups of four, and 15-digit Amex in 4-6-5. Format only.^(?:(?:\d{4}[ -]?){3}\d{4}|3[47]\d{2}[ -]?\d{6}[ -]?\d{5})$
Or browse the full regex library.
More from the workbench
Fine print
Tools: on the house.
Engineer: by the hour.
The regex was free. Code that doesn't need one is the upgrade: typed schemas, validated once at the edge, trusted everywhere after.
I'm Himanshu, an AI and full-stack engineer. I build MVPs, AI agents and the growth plumbing around them for early-stage startups.
