# Regex for Phone Number Validation

> Phone number regex for the international E.164 format, with a US-formatted variation and a breakdown of why phone validation should stay loose.

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

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.

## Token by token

| Token | Meaning |
|---|---|
| `^\+?` | 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 |

## Examples

- ✓ matches: `+14155552671`
- ✓ matches: `14155552671`
- ✓ matches: `+972501234567`
- ✗ does not match: `(415) 555-2671`
- ✗ does not match: `+0123456789`
- ✗ does not match: `12345`

## 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.

## FAQ

### 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

- [Regex for Email Validation](https://www.devkult.com/regex/email.md)
- [Regex for Username Validation](https://www.devkult.com/regex/username.md)
- [Regex for Dates in YYYY-MM-DD Format](https://www.devkult.com/regex/date-yyyy-mm-dd.md)

Open the interactive page: https://www.devkult.com/regex/phone-number