Developer and Text Tools

How to Store Phone Numbers Properly: E.164 and Country Codes

Why phone numbers should be stored in E.164, how trunk prefixes and shared calling codes work, and the difference between ISO alpha-2, alpha-3 and numeric.

Saizul Amin
Saizul Amin30 Oct 2026 · 3 min read
How to Store Phone Numbers Properly: E.164 and Country Codes

How to Store Phone Numbers Properly: E.164 and Country Codes

Phone numbers arrive in every imaginable format: 07911 123456, +44 (0)7911 123456, 0044 7911 123456, (415) 555-2671. Stored as typed, the same number appears several times in a database, SMS gateways reject half of them and nobody can tell which country a number belongs to. The free Country Codes and Phone Number Parser converts numbers to one standard form and lists every country's codes in one table.

E.164: one format to store

E.164 is the ITU's international numbering standard. A number in E.164 form is a plus sign, the country calling code and the national significant number, with no spaces or punctuation and at most 15 digits: +447911123456. Every messaging and telephony API expects it, it is unique for each line, and it sorts and compares cleanly. Store E.164 and format numbers for display when you show them.

Trunk prefixes

Inside many countries, people dial a 0 before national numbers: 020 for London, 07911 for a UK mobile, 01712 for a Bangladeshi mobile. That 0 is a trunk prefix, not part of the number, and it disappears in international form: +44 20, +44 7911, +880 1712. The written form +44 (0)20 is a common but confusing compromise. Italy is the exception: its fixed-line numbers keep the leading 0 internationally.

Shared calling codes

Calling codes do not map one-to-one to countries:

  • +1 is the North American Numbering Plan: the United States, Canada and more than twenty Caribbean and Pacific territories. The three-digit area code tells them apart, so +1 876 is Jamaica and +1 242 the Bahamas.
  • +44 covers the UK and the Crown Dependencies of Guernsey, Jersey and the Isle of Man.
  • +7 is shared by Russia and Kazakhstan, which uses numbers starting 6 and 7.

The parser uses area codes and number ranges where they decide the country, and your default country for ties.

National numbers need a country

A number written without + or 00, such as 020 7946 0958, could belong to any country that dials that way. The parser applies the default country you choose, removes the trunk prefix and adds the calling code. Set the default to the country where most of your users live.

Country codes: three kinds

ISO 3166-1 gives each country three codes:

  • Alpha-2, such as GB, DE and BD, used by internet domains, locale tags, currency codes and most APIs.
  • Alpha-3, such as GBR, DEU and BGD, used on passports, in statistics and in sport.
  • Numeric, such as 826, 276 and 050, which does not depend on the alphabet and stays stable when a country's name changes.

The internet domain usually matches alpha-2, with the well-known exception of the UK, which uses .uk rather than .gb. The table also shows each country's flag emoji, built from regional indicator letters.

What parsing cannot tell you

A well-formed number may still be unassigned, disconnected or a premium-rate line. Checking real number ranges and carriers needs a maintained library such as Google's libphonenumber or a lookup service. To confirm that someone owns a number, send a one-time code.

Step by step

  1. Paste numbers in any format, one per line.
  2. Choose the default country for numbers without + or 00.
  3. Read the E.164 form, country and display formats.
  4. Search the country table by name or code.
  5. Download either table as CSV.

Privacy

Numbers are parsed in your browser and never uploaded, which matters because phone numbers are personal data.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages