devkult_
tools26converters34
home/regex/phone-number

Regex for Phone Number Validation

Phone numbers are formatted a dozen ways, so the robust approach is: strip spaces, dashes, dots, and parentheses first, then validate the digits against E.164 — an optional +, no leading zero, 8 to 15 digits total. This pattern does exactly that. Validating the formatted string directly is the fragile path; there's a variation below if you must.

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

How it works, token by token

TokenMeaning
^\+?an optional leading + (escaped — bare + means 'one or more')
[1-9]first digit 1–9: E.164 numbers never start with 0
\d{7,14}7 to 14 more digits — 8 to 15 total, the E.164 length bounds
$end of string — no trailing characters

What it matches

+14155552671
14155552671
+972501234567
(415) 555-2671
+0123456789
12345

Try it live

One candidate per line — the m flag makes the ^ and $ anchors apply to each line. Edit anything; it runs in your browser.

/

Variations

^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$US 10-digit formats: (415) 555-2671, 415-555-2671, 415.555.2671
^\+?[\d\s().-]{8,20}$very loose: plausible phone characters only — pair with digit-count logic in code

Language notes

  • Normalize first: s.replace(/[\s().-]/g, "") in JavaScript, then test the E.164 pattern.
  • For anything user-facing (formatting, country detection), use libphonenumber — regex alone can't know that +1 415 is California.

Frequently asked questions

Why validate against E.164 instead of the formatted number?

Formats differ per country and per person — spaces vs dashes vs dots vs parentheses. Stripping punctuation and checking digits once beats maintaining a regex per format, and E.164 is what telephony APIs expect anyway.

Can a regex tell if a phone number is real?

No — it can only check shape. Country codes, area codes, and allocated ranges change constantly; libraries like libphonenumber embed that data, and the only certain test is sending an SMS or placing a call.

Related patterns

Building something custom? The regex tester gives you live match highlighting for any pattern.