In depth
How local numbers become E.164
E.164 is the international standard that writes every phone number as a plus sign, the country calling code and the digits, with no spaces or punctuation. The converter adds the calling code of the default country and removes the trunk prefix, the leading digit people dial for calls inside their own country. Here is real converter output for ten countries.
| Country | You typed | E.164 result | Trunk prefix removed |
|---|---|---|---|
| United States | (213) 373-4253 | +12133734253 | 1 |
| United Kingdom | 020 7946 0958 | +442079460958 | 0 |
| Germany | 030 123456 | +4930123456 | 0 |
| France | 01 23 45 67 89 | +33123456789 | 0 |
| India | 098765 43210 | +919876543210 | 0 |
| Australia | (02) 1234 5678 | +61212345678 | 0 |
| Japan | 03-1234-5678 | +81312345678 | 0 |
| Brazil | (11) 91234-5678 | +5511912345678 | 0 |
| Spain | 612 34 56 78 | +34612345678 | none |
| Italy | 06 1234 5678 | +390612345678 | none |
Why the leading 0 disappears
In the UK, Germany, France, India and many other countries, national numbers start with 0 when dialled inside the country. That 0 is a trunk prefix. It is not part of the number, so it is dropped when the country code is added: 020 7946 0958 becomes +442079460958, not +4402079460958. The US and Canada use 1 as the trunk prefix in the same way. Italy is the famous exception: its landline numbers keep the leading 0 even in international form, which is why the Italy row above ends up as +390612345678.
Why a number fails to convert
The converter never guesses. When a number cannot be converted it tells you why, using the library's own error codes. These are real results.
| Default country | Input | Result |
|---|---|---|
| United States | 12345 | TOO_SHORT |
| United States | (213) 373-425 | TOO_SHORT |
| United States | (213) 373-42531 | TOO_LONG |
| No default country | (213) 373-4253 | INVALID_COUNTRY |
| No default country | +9991112223333 | INVALID_COUNTRY |
| United States | call me | NOT_A_NUMBER |
| United States | hello 213 373 4253 | NOT_A_NUMBER |
Using E.164 in your own system
E.164 is the format SMS and voice APIs such as Twilio ask for, and it is the safest format for a database column: it is unique per number, sorts cleanly and needs no country context. Keep the original input in a separate column if you want to show it back to the user.