Skip to content

E.164, the format to store phone numbers in

E.164 is the ITU's recommendation for international telephone numbers: a country code of one to three digits, then the national significant number, fifteen digits at most. Written for machines it is a plus and the digits, nothing else: +447400123456. Store that form, and every other one follows from it.

From what people type to E.164

PlanTyped, national formE.164
United Kingdom07400 123456+447400123456
United States(201) 555-0123+12015550123
France06 12 34 56 78+33612345678
Italy02 1234 5678+390212345678

The national form carries a trunk prefix that E.164 drops: the 0 of 07400 123456, the 0 of the French number. Strip the punctuation and put +44 in front, and 07400 123456 becomes +4407400123456, which is not the number's E.164 form. Dropping every leading 0 instead breaks Italy: its plan has no trunk prefix, and the 0 of 02 1234 5678 stays in +390212345678. 101 of the 245 plans have no trunk prefix. Only the plan says which digits go, which is what the guides' parse reads from it.

How long a number can be

Why store E.164

The shape check, and what it does not check

A plus, then two to fifteen digits, the first not 0: ^\+[1-9][0-9]{1,14}$. Use it where a value must already be E.164, in a column constraint or at an API that accepts nothing else. It says nothing about the number: a string can have the shape and be no number in any plan. Input from people goes through parse, which knows the plans; the table shows the two side by side, with the United Kingdom, the United States, France and Italy loaded.

ValueShape checkparse returns
+447400123456passes+447400123456
+4407400123456passes+447400123456
447400123456failsnothing: no plan accepts it
+0447400123456failsnothing: no plan accepts it
+44 7400 123456fails+447400123456
+1234567890123456failsnothing: no plan accepts it

+4407400123456 passes the shape though it is not that number's E.164 form: the trunk prefix is still in it. parse reads it the way people write +44 (0)7400 123456 and returns the E.164 form.

Add it at the end of phone.mjs, the file from the JavaScript guide:

// E.164 as written for machines: a plus, then 2 to 15 digits, the first not 0.
const E164 = /^\+[1-9][0-9]{1,14}$/
export const isE164 = (s) => E164.test(s)

Sources: Recommendation E.164: The international public telecommunication numbering plan (ITU-T); Recommendation E.123: Notation for national and international telephone numbers (ITU-T); National numbering plans, ITU-T E.164 (ITU).