The Ultimate Guide To Cleaning Phone Numbers

Phone numbers are frequently used data types. So you would think they would be straightforward to work with, right? Right?

Well if you have phone numbers from multiple people and countries, it gets to be a mess.

You may find yourself having a spreadsheet with a bunch of different phone numbers and you’re stuck figuring out how to clean them.

If you want a quick way to do it, check out Clean Spreadsheets!

However, if you are trying to code or manually clean them yourself here is what you need to keep in mind.

What would cleaning a phone number do?

Cleaning a phone number will allow you to determine whether the number is valid and separate it into its components such as country code, area code and subscriber number.

Isn’t that straightforward?

You would think so but with different countries having different conventions, it gets out of hand quickly.

To limit this article getting too long, we will only be looking at the G20 countries. The top 19 largest economies of the world plus all the countries in the European Union.

Country Code

Each country in the world (and some territories) has a 1, 2 or 3 digit country code. This is prefixed with a plus sign (+).

The official E.123 guide recommends including the country code when storing numbers for international calling. However, when dialing within the country it is not required.

The country code (if it appears) will be at the beginning and most likely separated from the rest of the phone number

Rest of the Phone Number

Outside of the country code, phone number conventions differ from country to country.

Let’s take a look at each one of the G20 countries.

United States

Starting off, the United States and 24 other countries/territories share the North American Numbering Plan (NANP) with the format:

There is a 3 digit area code (AAA) followed by the 7 digit subscriber number. The N can only include numbers from 2 to 9.

The countries part of the NANP are: American Samoa, Anguilla, Antigua and Barbuda, Bahamas, Barbados, Bermuda, British Virgin Islands, Canada, Cayman Island, Dominica, Dominican Republic, Grenada, Guam, Jamaica, Montserrat, Northern Mariana Islands, Puerto Rico, Saint Kitts and Nevis, Saint Lucia, Saint Vincent and the Grenadines, Sint Maarten, Trinidad and Tobago, Turks and Caicos Islands, and United States Virgin Islands

The country code for the United States is +1.

Mexico

In Mexico, numbers are 10 digits long and the first number will be from 2–9. The area code can be 2 or 3 digits, followed by an 8 or 7 digit local number.

The format is:

  • AA NNNN XXXX or (AA) NNNN XXXX
  • AAA NNN XXXX or (AAA) NNN XXXX

The country code is +52.

Argentina

Phone numbers in Argentina have 11 digits.The area code always starts with 0 but can be 3–5 digits.

Phone numbers are usually formatted as:

  • (0AA) NNNN-XXXX
  • (0AAA) NNN-XXXX
  • (0AAAA) NN-XXXX

+54 is the country code and it replaces the 0.

Brazil

Landline

All landline phones are 10 digit numbers with the format:

  • AA NXXX-XXXX (N is a digit from 2 to 5)

Mobile

Meanwhile, all mobile phones are 11 digit numbers following the format:

  • AA NXXXX -XXXX (N is a digit from 6 to 9)

The country code is +55 added in front of the number.

South Africa

For local calls it starts off with the trunk prefix 0, a 2 digit area code and 7 remaining digits for the subscriber number. For international calls there is a +27 instead of the 0.

  • 0AA XXX XXXX
  • +27 AA XXX XXXX

China

Numbers can be 10 or 11 digits depending on area or type of phone.

Landline

  • 0AAA NNNN XXXX

The area code can be 2 or 3 digits and the local number can be 7 or 8 digits depending on the area.

Mobile

11 digit number following the format 1WX NNNN XXXX

WX is the service provider and W is always a number from 3–9

NNNN is the HLR code to determine the area and XXXX is the subscriber number.

International

The 0 is dropped and +86 is added

India

Phone numbers are 10 digits, excluding a 0 that’s required at all times. Numbers also fall into a few categories:

Landline

  • AAA-NNNNNNN

AAA is the Subscriber Trunk Dialing code or the long distance code and it can be 2–4 digits long. NNNNNNN is the phone number.

Mobile

  • AAAAA-NNNNN.

Non-local calls need to be prefixed by 0 or +91 which works for all of India and international.

Japan

Japan is similar to what we see in North America but there is a trunk code of 0 and international code of +81.

Some areas have a longer or shorter area code but the common format is:

  • 0AA NNN-XXXX

Republic of Korea

Phone numbers can be 7–11 digits long depending on if you’re making a local call where the area code isn’t required.

Landline

The area codes can be 2–3 digits depending on the city but the format is:

  • 0AA-NNN-XXXX or
  • (0AA) NNN-XXXX or
  • 0AA NNN XXXX

Mobile

For mobile phones it’s an 8 digit subscriber number and 01 and the area code in the beginning:

  • 01A-NNNN-XXXX

The country code is +82 and replaces the 0 when calling internationally.

Indonesia

Landlines use area codes while mobile phones do not.

Landline

Phones starts with a 0 when making domestic calls and +62 internationally. Numbers are 7 or 8 digits long.

  • AA NNNN-XXXX

Mobile

Numbers are 8–12 digits long and include a trunk prefix of 0, followed by 8NNN which is the mobile prefix.

  • 0 8NNN XXX XXXX

Saudi Arabia

The phone number is 7 digits and there is a 3 to 5 digit area code including a trunk prefix of 0. The international code is +966 that replaces the 0.

  • 0AA NNN XXXX

Australia

Numbers are 10 digits and written as

  • (0A) NNNN XXXX with +61 for international calls

For local calls the area code is optional.

Turkey

Numbers have a trunk prefix of 0 and the country code is +90 for calling internationally. The 0 is dropped when making calls outside of Turkey.

The common format for Turkish numbers is

  • 0AAA NNN XX NN

Landlines can have the prefix 02, 03, or 04

While mobile numbers have 05

European Union

Austria

Austria and a few other countries are part of the Open Numbering Plan so there is no standard length to the area code or subscriber number, but will range from 4–13 digits in total.

The international code is +43.

Landline

  • 1 NNN XXXX

Mobile

Phone numbers start with the number 6 and the format can be:

  • 6AA NNN XXXX

Bulgaria

Numbers are 8 or 9 digits in length, with an additional area code and have a trunk prefix of 0 or the country code of +359.

Landline

  • 0A NNN XXXX

Mobile

  • 0AAA NNN XXXX

Belgium

Phone numbers will start with a 0 and the “zone prefix” which can be 1–2 digits for landlines and 3 digits for mobile phones.

Landlines

Depending on the zone prefix numbers can be written as

  • 0AA NN NN NN or
  • 0A NNN NN NN

Mobile

The first digit of the zone prefix is always 4 and the format can be written as:

  • 04AA NN NN NN

Numbers can sometimes have a slash or dots between the zone prefix and subscriber’s number such as

  • 04AA/NN NN NN or
  • 04AA/NN.NN.NN or
  • 04AA/NNN.NNN

The international code prefix is +32 and drops the 0.

Croatia

The typical format is pretty to similar to some we have seen before. Numbers are usually 10 digits including a trunk prefix of 0.

  • (0AA) NNN XXXX

The area code in unnecessary to dial if you’re in the same area.

The country code is +385

Cyprus

Landline

Numbers start with a 2 and have the format:

  • 2A-XXXXXX

Mobile

Numbers start with 9 but have the same format:

  • 9A-XXXXXX

The international code is +357 that gets added in front of the number.

Czechia

The typical format is 9 digits such as AAA NNN XXX and the international code is +420.

Denmark

Numbers are 8 digits long and have no area code. The international code is +45 and common formats are:

  • NN NN NN NN
  • NNNN XXXX
  • NNNNNNNN

Estonia

Estonia has an open numbering plan and numbers are typically 7 to 12 digits. There are no area codes and the typical formats are:

Landlines

  • NNN XXXX

Mobile

  • NNNN XXXX

The country code is +372

Finland

This is another country with an open numbering plan and numbers can be 5 to 12 digits with a trunk prefix of 0 and an international code of +358 that will replace the 0.

Landline

All landlines start with 09 and have the format:

  • 09A NNNN XXXX

Mobile

Numbers can start with 04 or 05 depending on the mobile carrier, such as:

  • 04A NNN XXXX

France

There are 10 digit numbers and be written as

  • 0A NN NN NN NN or
  • 0A.NN.NN.NN.NN

The area code is a number between 1–5

For international calls the format drops the 0 and adds +33

Germany

Germany has an open number plan but are usually 10–12 digits long, with a trunk prefix of 0. The country code is +49 and replaces the 0.

A common format is:

  • (0AA) NNNN-XXXX

Greece

Phone numbers are usually 10 digits long but the area code is 2 or 3 digits and written as:

  • AAN XXXXXXX or
  • AAAN XXXXXX

The international code is +30 and goes in front of the number.

Hungary

Area codes are 2 digits and the subscribers number is 6 digits long. Cell phone numbers and phone numbers from Budapest are 7 digits in total. The country code is +36.

Ireland

Ireland also has an open numbering plan.

Area codes start with the trunk prefix 0 and can be 2 to 4 digits, followed by a local phone number being 7 digits.

Local numbers can be formatted as:

  • 5 digit numbers: NNNNN
  • 6-digit number: NNN XXX
  • 7-digit number: NNN XXXX

Hyphens are generally discouraged and mobile numbers are usually formatted as:

  • 08A NNN XXXX

The country code is +353

Italy

Another country with open telephone numbering plan but numbers can range from 6–11 digits.

The country code is +39.

Landline

Phones start with 0 followed by a prefix area code. An example of the format is:

  • 0A NNNXXXX

Mobile

Numbers start with 3 and are usually 10 digits long following the format:

  • 3AA NNNXXXX

Latvia

The country code is +361

Mobile

Phones all start with a 2 and have the format:

  • 2AA NN XXX

Landline

Landline numbers can start with a 5, 6, or 7 and follow the format:

  • 5 AA NNXXX

Lithuania

Area codes are 2 to 5 digits depending on the size of the town or city, and are followed by a national or local number that is 8 digits.

Every number starts with 8.

The country code is +370

Some common formats can include:

  • (8A) NNN XXXX
  • (8AA) NN XXXX

Luxembourg

Mobile phones have a 3-digit network code followed by 6 digit subscriber number such as:

  • 6X1 NNN XXX

Mobile numbers always starts with a 6 and the country code is +352

Malta

There is a prefix of 21 and the international code is +356, such as:

  • 21XX NNNN

Mobile

Phones have a prefix 99, 79, etc depending on the mobile carrier

  • 99XX NNNN

Netherlands

Numbers are 10 digits with a trunk prefix of ‘0’.

Landline

  • 0AA-NNNNNNN or
  • 0AAA-NNNNNN

Mobile

Phones have a 1 digit area code of 6, and 8 digits of the subscriber’s number:

  • 06-NXXXXXXX

N is never a 6 or 7

The country code is +31 and replaces the 0

Poland

Phone numbers are 9 digit numbers long and the country code is +48, which goes in front of the number.

Mobile

  • AAA-NNN-XXX

Landline

  • AA-NNN-XX-NN or
  • (AA)NNN-XX-NN

Portugal

Similar to Poland the numbers are 9 digits and written as AAA AAA AAA

All mobile numbers start with 9 and the country code is +351 that just goes in front of the number.

Romania

Phone numbers are 10 digits long, not including the trunk prefix 0.

Mobile and landline phones both follow the same format of:

  • 0AAA-XXX-XXX

The country code is +40 and goes in front of the number.

Russia

As we have seen before, it is common for some European countries to have an open numbering plan.

In Russia, numbers are 10 digits and the trunk prefix is 8.

Area codes vary by regions but are 3–5 digits and subscriber number is separated by dashes.

The common format is

  • 8 (AAA) NNN-NN-XX

For international callers, the country code is +7

Spain

Numbers are 9 digits and start with 9 or 8 for landlines and 6 or 7 for mobile phones.

Numbers can be written as

  • AA NNN XX NN or
  • AAA NNN XXX depending on the length of the area code.

The country code is +34 and goes in front of the number.

Slovenia

All numbers are 9 digits, including a trunk prefix of 0.

The country code is +386 and replaces the 0.

The area code can be 1–3 digits and possible formats are:

  • (0A) NNN XX XX or
  • (0AA) NNN XXX or
  • (0AAA) NN XXX

Sweden

Sweden has an open numbering plan so number formats vary by length but have a trunk prefix of 0. The country code is +46 and replaces the 0 when calling internationally.

10 Digit Number

  • 0A-NNN XXX XX or
  • 0AA-NNN XX XX or
  • 0AAA-NN XX XX

9-Digit Number

  • 0A-NNN XX XX or
  • 0AA-NNN XX XX or
  • 0AAA-NNN XX

8-Digit Number

  • 0A-NN XX XX or
  • 0AA-NNN XX

Mobile

Numbers are 10 Digits and always start with 7. Such as:

  • 07A-NNN XX XX or
  • 07AA-NN XX XX

United Kingdom

The length of numbers ranges from 7 to 10 digits since there is an open numbering plan.

The trunk prefix is 0 and country code is +44, which replaces the 0 when calling from outside the U.K.

A common format is:

  • (0AAA) NNN XXXX

Mobile

Mobile phones start with 7 and vary by cell phone provider but a common format is:

  • 07AAA NNN XXX

Closing Remarks

You can use this guide to come up with an implementation to clean phone numbers from your database, programming language or spreadsheets.

And if you need to clean numbers in spreadsheets, you can check out our tool Clean Spreadsheets to automatically clean and transform any phone numbers in your spreadsheets.

Happy Data Cleaning!

Written by

Products and resources that magically simplify hard spreadsheet tasks. Check us out at www.lovespreadsheets.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store