Advertisement

Phone Number Regex Tester

Tested phone number regex patterns for US/Canada, E.164, UK and Indian mobiles and international numbers. Check a list line by line and copy the code.

Phone formats differ by country, so there is no single phone-number regex that is both strict and universal. This tool gives you tested patterns for the formats people ask about most — US and Canada (NANP), strict E.164, UK mobiles, Indian mobiles and a flexible international check — tests each line against the one you choose, explains why a number fails, and writes the code for JavaScript, Python, PHP or Java.

How to use this tool

  1. Pick the pattern for the numbers you accept.
  2. Paste numbers one per line, or choose the extractor to find US and Canadian numbers inside text.
  3. Read the Valid and Invalid counts and the reason for each failing line.
  4. Copy the snippet for your language.

Formula

E.164: ^\+[1-9]\d{1,14}$ · NANP: ^(?:\+?1[-. ]?)?(?:\([2-9]\d{2}\)|[2-9]\d{2})[-. ]?[2-9]\d{2}[-. ]?\d{4}$

E.164 numbers are a + followed by at most 15 digits, and country codes never start with 0. In the North American plan the 3-digit area code and the 3-digit exchange both start with 2–9. The UK pattern covers 071–075 and 077–079, plus the Isle of Man 07624 exception; 070 personal numbers and other 076 paging numbers are excluded. Indian mobiles have 10 digits starting with 6–9, optionally after +91, 91 or 0. The flexible pattern only requires 7–15 digits with optional +, spaces, dots, hyphens and brackets. These are format checks, not complete allocation rules. Cross-language whitespace classes can differ; test non-ASCII input in the target runtime. Tables show at most 400 rows.

Example

With the default list and US / Canada, 3 of 7 lines pass: (415) 555-2671, +1 415 555 2671 and 415.555.2671. 123-456-7890 fails because no area code starts with 1, 555-2671 has only 7 digits, and the UK and Indian numbers have 12 digits. Flexible international accepts all 7, while UK mobile and India mobile accept one line each.

Frequently asked questions

Should I store numbers in E.164?

An international +country-code form is useful for storage. Use a numbering-plan library to interpret local numbers and remove national trunk prefixes correctly. The displayed E.164-style regex only checks the overall shape; it does not verify a country code or a national numbering plan.

Does a match mean the number exists?

No. A regex only checks the shape. Whether a number is assigned, mobile or reachable needs a carrier lookup or a one-time code sent by SMS.

Why not just count digits?

Counting digits catches most typos, and it is what the flexible pattern does. Country patterns add structure, such as rejecting US area codes that begin with 0 or 1, which the numbering plan never assigns.

Are 555 numbers real?

The block 555-0100 to 555-0199 is reserved for fictional use in North America. Such numbers have a valid format, so the patterns accept them even though they never ring.

Sources

Last updated: 2026-10-30

Advertisement