Technical
Phone number formats and E.164, explained
The same phone number is written a dozen ways, and a database that stores them as typed cannot match, dedupe or dial them reliably. The fix is to store one canonical international form and format it for display at the edge. This guide covers what that form is, what the parts of a number mean, how extensions fit, and what the LookValid phone check accepts and returns.
What E.164 is and why you store it
E.164 is the ITU-T recommendation titled "The international public telecommunication numbering plan" 1. In practice it defines the shape of a number you can dial from anywhere: a country calling code followed by the national significant number, written with a leading plus sign. The plus sign is notation for "an international dialling prefix goes here", and the prefix itself differs by country, so it is not stored.
An E.164 number is limited to 15 digits in total, the country code included 2. That makes it short enough for a fixed column and unambiguous enough to use as a key, which is why it is the right form to store. Everything else is presentation.
- Store
+12025550143: a plus, then digits only, no spaces, dashes or brackets. - Keep the number and its extension in separate columns, because an extension is not part of E.164.
- Format for display from the stored value, in the reader's own convention.
Country codes, national numbers and prefixes
The country calling code is one to three digits for a geographic area 2. The rest is the national significant number, and its internal layout is a national matter: each country decides how many digits it has and how they are grouped 2. Several countries can share a code. Code 1 belongs to the North American Numbering Plan, which includes the United States and its territories, Canada and some Caribbean countries 3.
The leading digit people dial before a local number inside their own country is a national prefix, not part of the number. In the United Kingdom a London number is written 020 7946 0018 at home and +44 20 7946 0018 abroad: the 0 is dropped once the country code is present. That is why you display the national form to local users and store the international one, and why a parser needs to know the country of a number written without a plus sign.
| Part | Rule | Stored in E.164? |
|---|---|---|
| Leading plus | Marks an international number | Yes |
| Country calling code | 1 to 3 digits for a geographic area | Yes |
| National significant number | Layout set by each country | Yes |
| National prefix, such as a leading 0 | Dialled only inside the country | No |
| Spaces, dashes, brackets, dots | Presentation only | No |
| Extension | Reached after the call connects | No, store separately |
Format rules at a glance
What our phone check does with real input
The LookValid phone check reads a number with an optional two-letter country hint, and assumes US when you send none. It checks the number against the numbering plan and returns the E.164, national and international formats, the calling code, the country, the number type the plan assigns and, for North American numbers, the area code and its region. It never contacts a carrier, so it cannot tell you whether a line is switched on or has been ported.
We ran the live provider on reserved example numbers. These are the actual outputs.
| Input | Country hint | E.164 | National format | Type | Extension |
|---|---|---|---|---|---|
| +1 202 555 0143 | none | +12025550143 | (202) 555-0143 | fixed_line_or_mobile | null |
| (202) 555-0143 | US | +12025550143 | (202) 555-0143 | fixed_line_or_mobile | null |
| 020 7946 0018 | GB | +442079460018 | 020 7946 0018 | fixed_line | null |
| +44 20 7946 0018 | none | +442079460018 | 020 7946 0018 | fixed_line | null |
| +1 202 555 0143 ext. 22 | none | +12025550143 | (202) 555-0143 | fixed_line_or_mobile | 22 |
| 202-555-0143 x7 | US | +12025550143 | (202) 555-0143 | fixed_line_or_mobile | 7 |
Phone check output for example inputs
Four inputs spelled in different ways collapse to two E.164 values, and the UK number with the leading 0 and the one with +44 give the same result. A number with letters in its body, such as +12025550143abc, is refused as invalid input, and 12345 with a US hint comes back as not found because its length does not match the plan for +1. A number the plan rejects costs nothing.
A found number is billed at 1 credit per the catalog.
Extensions
The check splits a trailing extension of one to eight digits off the end of the input before it reads the number, so ext. 22, x7 and #12 all work. The extension comes back in its own extension field and is never folded into e164. Two inputs that differ only by extension are different lookups, so store the two values side by side and join them only when you dial.
curl -X POST https://YOUR_API_HOST/v1/phone \
-H "Authorization: Bearer $LOOKVALID_API_KEY" \
-H "Content-Type: application/json" \
-d '{"phone":"020 7946 0018","country":"GB"}'
One phone lookup with a country hint
A storage checklist
- Validate at the point of entry and ask for the country when the user does not type a plus sign.
- Store the
e164value from the result, not the typed string. - Store the extension and the two-letter country in their own columns.
- Render national format for local users and international format for everyone else.
- Treat the number type as a hint from the plan. It is not a carrier lookup.
Try the phone number validator in the browser, check a calling code with the country code lookup, read the docs, or follow the Python tutorial to clean a whole list.