All posts

Phone Number Formats by Country: E.164, NANP, and How to Test Them

July 21, 2026 · DevTools

phone number
test data
e.164
nanp
qa

A phone-number field is one of the most fragile inputs in any form. Users type spaces, dashes, dots, parentheses, country codes with or without the +, and national prefixes they picked up from a previous country. On the receiving side, your code has to decide whether to store the value raw, format it for display, or hand it to an SMS provider that expects strict E.164.

A phone-number generator that emits numbers in the formats you actually have to support lets you test all of those paths without ever touching a real subscriber. Try every example below in the Phone Number Generator.

Anatomy of a phone number

Every phone number has four parts that determine whether it's well-formed:

  • Country calling code1 for the NANP region (US, Canada), 44 for the UK, 49 for Germany, 91 for India. Always prefixed with + in international form.
  • Area or operator code415 for San Francisco, 020 for London, 030 for Berlin, 22 for Mumbai. Mobile numbers in many countries use an operator prefix instead.
  • Subscriber number — the remaining digits assigned to the line.
  • National writing convention — how the digits are grouped for humans (+1 (415) 555-0123, 020 7946 0958, +49 30 12345678).

Length, prefix ranges, and grouping all vary per country, which is why a "generate a random 10-digit number" approach breaks the moment your validation gets serious.

Step 1: Pick a country

The country selection loads the calling code, the local length rules, and the available number types. Twenty-one countries are supported.

Step 2: Pick the number type

Three categories cover most cases:

  • Mobile — a cellular subscriber line. Useful for testing SMS flows and mobile-only validation.
  • Landline — a fixed geographic line tied to an area code. Useful for testing address/phone pairing.
  • Toll-free — for the US and Canada, numbers in the +1 (800), +1 (888), +1 (877) etc. range that don't bill the caller. Also premium-rate numbers (e.g. +1 (900)) when you need to test a high-cost path.

For the US and Canada, the generator uses real NANP area codes and avoids reserved codes like 911, 411, and the 555-0100 through 555-0199 range reserved for fiction — though the latter still appear in many test suites, so the tool includes them where useful.

Step 3: Pick the output format

Four formats cover what your code is likely to expect:

  • International+1 (415) 555-0123. Best for display and for any downstream service that wants strict E.164 with formatting.
  • National(415) 555-0123 for the US, 020 7946 0958 for the UK. What users actually type.
  • Raw digits14155550123. What a database column or a CSV import expects, and the closest format to E.164 without the +.
  • RFC 3966 (tel:)tel:+1-415-555-0123. The format used in href="tel:..." links and in SIP/VoIP integrations.

Step 4: Generate and validate

Set the count to up to 50 and click generate. For a batch destined for a seed CSV, raw digits is usually the right format:

14155550123
14155550198
14155550212
4155550167

The Validator tab takes a single number, the country, and the type, and confirms whether the length and leading digits match the expected shape. It's a sanity check before you commit a fix to your regex.

Deeper dive: E.164 vs RFC 3966

E.164 is the ITU standard: a +, a country code, and the national number, with no separators, up to 15 digits total. +14155550123 is E.164. +1 (415) 555-0123 is not, because of the spaces and parentheses — but it's the same number written in display form.

RFC 3966 wraps E.164 in a tel: URI with hyphens allowed as visual separators: tel:+1-415-555-0123. Browsers, mobile dialers, and SIP clients all parse this format directly. If your UI exposes a click-to-call link, RFC 3966 is what you want.

A practical test-data pipeline usually stores the raw E.164 form and renders a formatted version for display. Both come out of the generator.

Why not real numbers

The numbers are valid in shape but randomized — they do not belong to real subscribers. They are test data for input validation, seeding, and placeholder UI, and they must not be used to impersonate, spam, or test any production SMS provider's deliverability.

Everything stays in your browser

The generator runs entirely client-side. Numbers are produced locally; nothing is uploaded, nothing is logged. You can use it in any environment, including on a flight or behind a strict corporate firewall.

Next: identity numbers for the same locale

A phone number is rarely the only PII field on a form. The next guide covers how driver's licenses are formatted by state and country: read Driver's License Number Formats by Country and State or jump straight into the Driver's License Generator.