E.164: The Phone Number Format Databases Should Store

💡 15K+ searches/mo⏱️ 8 min read

Phone numbers are the most commonly mangled data field in existence, and the mangle always starts the same way: someone stored what the user typed. Here's the one format that doesn't lose information, the country rules that break naive parsing, and the checks that matter — all with numbers you can verify.

Advertisement

One format to store

E.164 is the ITU standard that defines how a globally unique phone number is written: a plus sign, the country calling code, then the national significant number (NSN) — the part that actually identifies the subscriber. No spaces, no dashes, no parentheses, no leading zeros. Maximum 15 digits including the country code.

Every other way of writing a number either loses the country (national format), loses uniqueness (a bare 10-digit string could be US, CA, or a dozen other +1 countries, or a Caribbean island), or carries decoration that varies by who typed it. Store E.164; render beautifully elsewhere.

The trunk prefix trap

Most of the world dials a leading 0 to escape the local network. The UK, Germany, France, Spain, the Netherlands, Australia, Japan, Nigeria — all trunk-prefix countries. The rule people get wrong: the trunk prefix is part of the domestic dialing ritual, not part of the number.

CountryYou dial domesticallyE.164NSN
United Kingdom020 7031 3000+44207031300010 digits
Germany030 901820+49309018208 digits
France01 42 68 53 00+331426853009 digits
Australia(02) 9250 7111+612925071119 digits
Japan03-3212-1111+813321211119 digits
United States(415) 555-2671+1415555267110 digits

See the pattern? Strip the 0, prepend the country code. The US row looks the same only because North America never had a trunk prefix — its "1" is the country code it happens to share with Canada and 20-odd Caribbean nations, which is also why a bare "10-digit US number" is ambiguous the moment a Canadian signs up.

The classic import bug: a spreadsheet of UK numbers in national format, someone strips punctuation and prepends +44 without removing the 0, and every SMS to +4402070313000 silently fails. The 0 goes. Always.

Possible vs valid

Two checks, two meanings, and conflating them is how validation bugs ship:

  1. Possible — the length fits one of the country's allowed NSN ranges. +1 300-555-0100: ten digits, possible. A cheap sanity check while someone is typing.
  2. Valid — the leading digits match an allocated block. Area code 300 is unassigned, so that number is possible but not valid.

What neither check tells you: whether anyone actually holds the number. Metadata knows the map, not the residents. Confirming possession takes an SMS code or a call — which is why every serious signup flow validates format offline first, then verifies ownership out-of-band.

Line type, and its honest limits

Numbering plans that encode line type in the prefix let metadata distinguish them: UK 07-prefixed numbers are mobile, 02-prefixed are fixed. Brazil's mobiles carry the 9. But the US and Canada lump everything as "fixed or mobile" because NANP allocation doesn't separate them. And portability — moving a number between carriers, or fixed-to-mobile — means the type baked into the prefix can drift from reality. Type is a strong hint, not a guarantee; if your flow depends on "this is definitely a mobile," an SMS handshake is the only proof.

Doing it right in four steps

  1. Accept anything — let users type numbers however they like, with a country selector for non-plus input.
  2. Parse with real metadata — Google's libphonenumber (or libphonenumber-js on the web) knows every country's ranges and prefixes. Regexes for phone numbers are a spectator sport.
  3. Store E.164 — one column, one format, unique and sortable.
  4. Format at display — national format for domestic users, international for everyone else, and tel:+14155552671 (RFC 3966) for links and QR codes.

Step 2 is where our phone number validator lives: paste any number, get the verdict plus all four formats, with the entire Google dataset running in your browser — no API, so customer lists stay home.

Validate a number right now

Paste any number, get validity, E.164, and line type — offline metadata, zero uploads.

Phone Number Validator →

The bottom line

Phone number handling goes wrong at the storage boundary, not the input boundary. Accept generously, parse with real metadata, store E.164, format for humans on the way out — and respect the trunk prefix, because that 0 is the single most expensive character in telecom data. The validator covers the parse-and-check step; for the QR side of step 4, the QR code generator takes tel: URIs directly.

Advertisement

Frequently Asked Questions

What does an E.164 number look like?

A plus sign, the country calling code, and the national significant number — no spaces, dashes, parentheses, or leading zeros. A San Francisco number is +14155552671 in E.164; the same number written (415) 555-2671 is US national format and 4155552671 without the country code is not globally unique. Fifteen digits is the ITU maximum, including the country code.

Why do UK numbers start with 0 sometimes and not others?

The 0 is a trunk prefix — the digit you dial to get out of the local network, used by the UK, Germany, France, Japan, Australia, and dozens of others. You dial 020 7031 3000 inside the UK but write +44 20 7031 3000 internationally, because E.164 drops the trunk prefix. The US and Canada never had one, which is why (415) 555-2671 loses nothing but punctuation going to +14155552671.

Should I store phone numbers as E.164 in my database?

Yes — it's the only format that is simultaneously unique, sortable, and dialable. Store E.164, validate at the door with libphonenumber-style metadata, and render national or international format at display time. Storing formatted numbers means every dedupe, search, and SMS send fights inconsistent punctuation, and two rows can hold the same number.

What's the difference between a valid and a possible phone number?

Possible means the length fits one of the country's allowed ranges — the number could exist. Valid means the leading digits also match an allocated block. +1 300-555-0100 is possible but not valid: ten digits like a US number, but area code 300 is unassigned. Neither check confirms the number is in service; only a call or SMS does that.

How many digits can a phone number have?

Fifteen total in E.164, country code included, per the ITU standard. Real national significant numbers run from about 8 digits (Germany's fixed lines) to 11 (Brazil's mobiles); the US and Canada use 10. Numbers longer than 15 digits after the plus are either mistyped or carry an extension, which belongs in a separate field.

Related Tools