US phone number regex
US phone number that accepts every common formatting people actually type.
^(?:\+?1[\s-.]?)?(?:\(\d{3}\)|\d{3})[\s-.]?\d{3}[\s-.]?\d{4}$/What it matches
Real users type phone numbers a dozen different ways: `555-555-5555`, `(555) 555-5555`, `+1 555.555.5555`, `5555555555`. This pattern accepts an optional `+1` or `1` prefix, then a 3-digit area code (optionally in parentheses), then the 7-digit subscriber number, with any combination of space, hyphen, dot, or nothing as separators.
Examples
Matches
555-555-5555Hyphen-separated, the most common written form.
(555) 555-5555Parenthesized area code, space, hyphen.
+1 555 555 5555International prefix, space-separated.
5555555555No separators at all — the form an autocomplete usually returns.
1.555.555.5555Dot-separated with `1` prefix.
Does not match
12345Wrong length.
555-55-5555Wrong segment lengths (looks like an SSN).
+44 20 7946 0958International number — would need a different pattern.
(555 555-5555Unbalanced parenthesis.
Edge cases & gotchas
- Accepts area codes that don't actually exist (`000`, `911`). The North American Numbering Plan reserves several — if you need real validity, use libphonenumber.
- Doesn't normalize — `555-555-5555` and `5555555555` both match but compare unequal. Strip non-digits with `.replace(/\D/g, '')` to get a canonical form.
- Accepts mixed separators (`555-555.5555`). Most users won't type that, but the pattern allows it for flexibility.
- Doesn't accept extensions (`555-555-5555 x1234`). Add `(?:\s?x\s?\d+)?` at the end if you need them.
In your language
// JavaScript
const re = /^(?:\+?1[\s-.]?)?(?:\(\d{3}\)|\d{3})[\s-.]?\d{3}[\s-.]?\d{4}$/;
const match = "input".match(re);All 13 languages (including Bash, Perl, Kotlin, Swift) available in the full toolkit Export tab.
Notes for production
- For real-world phone validation use Google's libphonenumber — it handles every country, recognizes mobile vs landline, and formats consistently. Available as `libphonenumber-js` on npm.
- Tel input formatting libraries like `cleave.js` or `react-imask` give nice UX without dealing with the regex yourself.
Frequently asked
How do I make this work for non-US phone numbers?
Don't — international phone numbers vary too much for one regex. Use Google's libphonenumber library, which has parsers and validators per country.
Why does `911` match as an area code?
Because we don't enforce the North American Numbering Plan rules. If you need to reject reserved area codes, list them in a negative lookahead or do it in code after the regex check.
How do I store the number after validation?
Strip to digits only (`.replace(/\D/g, '')`) and store the canonical `E.164` form (`+15555555555`). Format for display on read.