Geocoding and postal codes

The problem

Many software developers have misconceptions about postal codes (usually referred to as zipcodes in the United States) and how they relate to geographic areas.

We hope that this guide will help cast light on some of the common misconceptions, and thus help prevent developers from building applications based on faulty logic.

One of the most common problems we see is developers struggling when the assumptions they made about postcodes based on their home country turn out not to be valid in other countries.


The key point to understand is that postal codes are a tool used by postal services to speed up the delivery of physical mail. In some parts of the world postal codes have become a shorthand way to refer to areas, and this has lead to a mistaken, albeit understandable, perception that postcodes always correspond to locations.

Common points of confusion and misconceptions

Postcodes always represent locations

No, for most countries postcodes represent mail delivery points. Those points may or may not be in fixed locations. For example, many countries assign postcodes to military units. The postcodes stays the same regardless of where the unit is physically based. In many countries large companies or government departments have their own postal code with no correlation to physical location.

Postcodes never move or change

No, in most countries there is on-going fluctuations in postcodes. New postcodes are created, old codes are retired, large organization move and take their code with them. Occasionally countries will change their entire postcode system (fun!).

Postcodes work roughly the same way in all countries

No, not at all. Almost every aspect of what a postcode is and what it means can differ across countries. The format of the code, the number of people it represents, etc, etc.

All countries have postcodes

No, many countries do not have any form of postal code at all. Also, some countries technically have a postcode system, but it is not widely used.

Every geographic location belongs to a certain, unique postcode region.

While some countries have assigned postcode regions to all of their territory, many others have not. Remote locations, for example in a large forest, or lakes or other bodies of water, may not fall into any postal region.

A geographic location can only have a single, unique postcode

In some countries that is the case, but in others it is not. Usually it will depend on how many people are at the location (and thus how much mail typically needs to be sent there) An example: skyscrapers in New York can have multiple zip codes.

Postal systems are unique to a specific country

No, many countries and territories of the world use the postal service of other countries. For example Liechtenstein uses the Swiss postal system. For logitical convenience, exclaves of one country often use the postal system of another country. For example the German exclave Büsingen uses both the German and Swiss postal services.

Postcodes are unique to a specific country

No, many countries use sttrings of numbers as their postal code. So if you just send us a query like 12345 we have no idea which country you mean. Please always also add a country name.

Postcodes are always numbers

No, many countries like the UK and Canada have alphanumeric codes. Some countries require dashes or spaces in their codes. But even in countries that use only digits in their postal codes it is best to always treat postcodes as strings not numbers, otherwise leading zeros can get removed by formatting software (for example Excel). This is one of the most common problems we see in geocoding query formatting .

So what should software developers do?

The first thing is you should understand and internalize that postcodes are not a great tool for communicating location. They should be avoided if possible. Nevertheless, we understand that in some countries the habit of searching by postcode or referring to locations by postcode has become entrenched.

Even in that case it's important to understand the inherent limitations and challenges of using postcodes to reference locations. Know the potential problems you are building into your system.

If your application will be geocoding multiple countries do NOT fall into the trap of assuming postal codes have the same characteristics in all countries (or even that all countries have postcodes)

Final point: treat postcodes as string not numbers. You will thank us.

Further Reading

Happy geocoding!

Start your free trial

2,500 API requests per day.

No credit card required.