Regex for Phone Numbers

Test a regex for phone numbers that accepts common US and international formats such as +1 555-123-4567. Try your own examples live.

Part of the free Regex Tester. Runs in your browser — nothing is uploaded.

Regex for Phone Numbers

Phone numbers come with country codes, spaces, dashes and parentheses. This pattern accepts an optional country code and a 10-digit number written in the usual styles. Adjust it for your region.

Worked example: Common phone formats

Pattern /^\+?\d{1,3}[\s-]?\(?\d{3}\)?[\s-]?\d{3}[\s-]?\d{4}$/ — test strings

^\+?\d{1,3}[\s-]?\(?\d{3}\)?[\s-]?\d{3}[\s-]?\d{4}$

+1 555-123-4567
(555) 123-4567
555 123 4567
12345
abc-def-ghij

Result for each line

✓ match     +1 555-123-4567
✗ no match  (555) 123-4567
✗ no match  555 123 4567
✗ no match  12345
✗ no match  abc-def-ghij

Practical tip

Store phone numbers in E.164 format (+15551234567) and use a library such as libphonenumber for real validation across countries.

How to use this Regex Tester

  1. 1Use the live tool above — it runs entirely in your browser and never uploads your data.
  2. 2Paste the sample from the worked example, or use your own input.
  3. 3Copy the result, then adapt the same steps in your editor, script, or pipeline.

Regex for Phone Numbers FAQs

Is a regex enough to validate phone numbers?

It is fine for basic format checks. Valid lengths and area codes differ by country, so use libphonenumber for accuracy.

What is E.164?

E.164 is the international format: a plus sign, country code and number with no spaces or punctuation, up to 15 digits.

More Regex Tester pages

Open the full Regex Tester tool →