What are the correct postcode formats around the world?

Everything developers need to know about international postcode formats

The AI-created picture shows mailboxes in various colors
The AI-created picture shows mailboxes in various colors

We all use postcodes every day. We use them to post mail, or fill out forms online. Developers use them to solve location-based tasks, or build apps.

But what exactly is a postcode? Is it different from a ZIP code? Do they differ between countries?

A postcode is a series of numbers, or letters and numbers, that's used for sorting mail. Postcodes were first introduced in 1857 in London, UK, to divide the city into ten districts and make mail delivery easier.

In this guide, we delve into the various postcode formats used globally and demonstrate how to effectively parse postcodes using regular expressions (regex). Additionally, we explore the practical application of Geoapify's Geocoding API, a powerful tool for developers that facilitates the searching and handling of postcodes within their projects.

Let's take a closer look at some of the most common postcode formats in use today, and how you can find the postcode formats you need to solve the task at hand.

Are there different names for postcodes?

Yes, there are lots of different names for postcodes around the world. For example:

  • A ZIP code is a type of postal code used in the United States and the Philippines.
  • CAP is an Italian postal code (it stands for "codice di avviamento postale" or postal expedition code).
  • Irish postcodes are called Eircodes.
  • In India, the mail service uses a Postal Index Number, or PIN.
  • Postal code is the most popular term in Canada.
  • Many English-speaking countries say postcode.

What are the most common postcode formats?

The most common postcode format is numerical. However, some places use an alphanumeric postal code system, including Argentina, Canada, the UK, Brunei, Malta and the Netherlands.

Alphanumeric systems make it possible to code many more addresses in one place, because you can build more variations using letters and numbers together, than from numbers alone.

Are postcode formats different around the world?

Yes, there are many postal code formats in use around the world. Let's take a look at a few numeric and alphanumeric examples.

United Kingdom

UK postcodes are alphanumeric. UK postcodes have two alphanumeric codes that show the post town, and then the addresses in that post town. The first code is the Outcode, and has between two and four characters that show the postcode area and district.

2 gidit postcodes in UK
2-digit postcodes Great Britain: postcode areas, described through the first two digits of the British postcode system. The original image can be found here.

For example, EX covers Exeter in the Southwest UK, and several towns around it. X38 denotes Great Torrington, a small town around 35 miles from Exeter. The second code is the Incode, and it always has three characters, and always starts with a number. The Incode shows the postcode sector and delivery point. For example, EX38 7DJ is an area on the outskirts of Great Torrington that includes the main school and an industrial park.

More examples of UK postcodes:

PostcodeLocationCity
SW1A 1AABuckingham PalaceLondon
EH1 1BBNear Scottish ParliamentEdinburgh
L1 8JQClose to Liverpool Central railway stationLiverpool
B1 1TBNear Birmingham New Street stationBirmingham
CF10 1EPClose to Cardiff CastleCardiff

United States

The USA first introduced ZIP codes in 1963. ZIP stands for Zone Improvement Plan. The postal service chose ZIP as an acronym to conjure up an image of the mail zipping along to its destination! Each ZIP code has five digits.

The first digit in a ZIP code represents the broad area, such as Northeast. The next two show the central mail processing facility. The fourth and fifth digits point to the smaller post office or postal zone within that area. For example, if the ZIP code is 10014, the 1 is for Delaware, New York, Pennsylvania, while the 00 is for the New York Sectional Processing Center. 14 shows the area of Manhattan (the West Village and Meatpacking areas.)

Some places use ZIP+4 codes that add a hyphen and four extra numbers to give a more specific location, such as an office, apartment building, or a span of a few blocks. However, ZIP+4 codes aren't mandatory.

Here's the list of ZIP codes examples:

ZIP CodeCityState
10001New YorkNY
90210Beverly HillsCA
60601ChicagoIL
20001WashingtonDC
30301AtlantaGA

Canada

Canada also uses alphanumeric postal codes, consisting of a string of six characters. Canada first started using postal codes in 1925, to divide Toronto into districts. By 1943, Toronto was divided into 14 zones, and postcode use began to spread across the country.

The first three digits of the postal code are the Forward Sortation Area. The letter shows the postal district which is usually an entire territory or province, aside from in Quebec and Ontario.

Components of a Canadian postal code

The second digit shows whether an area is rural (0) or urban (all other digits.) The second letter specifies a region such as a small city, or a specific area of a larger city. The last three characters show the Local Delivery Unit, a specific address or range of addresses. For example, V5K 3A9 stands for Vancouver, and specifically the area by Granville Island.

Here's a table with examples of Canadian postal codes:

Postal CodeLocationProvince/Territory
M5H 2N2Near Toronto City HallOntario
H3C 3J7Near Old Port of MontrealQuebec
V6B 6G1Near Vancouver Art GalleryBritish Columbia
T2P 1J9Near Calgary TowerAlberta
R3C 4T7Near The Forks, WinnipegManitoba

Germany

Germany started using postcodes in 1941. From 1965, West Germany had its own system, with East Germany devising its own system shortly after. From 1993, Germany has had a standard country-wide postal code system. Unlike the examples above, Germany's postal system uses a numeric code only.

German postcode information
Map of postal codes with zones of the first 2 digits of the postal code and the federal state borders. The original image can be found here.

The first two digits indicate the area or city. For example 10 represents Berlin while 20 represents Hamburg. The last three show the postal district. So 20095 would show Hamburg, Hamburg-Altstadt, Hamburg-Mitte areas.

Here are examples of German Postleitzahlen (PLZ, the German equivalent of postal codes) in a table format:

PLZCity/TownRegion/State
10115BerlinBerlin
20095HamburgHamburg
80331MunichBavaria
50667CologneNorth Rhine-Westphalia
60311FrankfurtHesse

India

India uses a Postal Index Number (PIN), a six-digit code that was introduced in 1972.

Components of a Canadian postal code

The first number of the PIN shows the zone (there are nine postal zones.) The second shows the sub-zone, and the third the sorting district. The last three digits indicate the specific post office within that district. For example, PIN 700031 shows East of the country (7) and specifically the West Bengal area (70.) The third digit shows the sorting district - in this case, Kolkata (0.) The last three digits (031) show us that the address is in the Dhakuria Post Office region.

Here's a table with examples of Indian PIN (Postal Index Number) codes:

PIN CodeLocationState/Union Territory
110001Connaught PlaceDelhi
700001Kolkata GPOWest Bengal
400001Mumbai GPOMaharashtra
600001Chennai GPOTamil Nadu
560001Bangalore GPOKarnataka

How can Regex help developers parse and validate the postcodes?

Utilizing regex (regular expressions) can streamline the way developers extract postcodes. By leveraging the consistent pattern of a postcode from a particular region, regex can effectively identify and parse similar postcodes within that area.

Consider the following regex examples:

UK Postcodes

  • Regex: /([A-Za-z][A-Ha-hJ-Yj-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})/g
  • This regex accounts for the various formats of UK postcodes, which can include letters and numbers.
  • Find more regex examples here.

US ZIP codes

  • Regex for 5-digit ZIP: /\d{5}/g
  • Regex for 5-digit and ZIP+4: /\d{5}(?:[-\s]\d{4})?/g
  • These expressions match the standard 5-digit ZIP code and the ZIP+4 code format, respectively.
  • Find more regex examples here.

German (DE) Postcodes (PLZ)

  • Regex: /\d{5}/g
  • German postcodes are five digits, making this regex straightforward.

Canadian Postal Codes

  • Regex: /[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d/g
  • Canadian postal codes follow a specific alphanumeric pattern, alternating letters and numbers.
  • Find more regex examples here.

Indian PIN Codes

  • Regex: /\d{6}/g
  • Indian PIN codes are six-digit numbers, captured by this simple numeric regex.

How else can developers parse and validate postcodes?

An API can help you parse and validate postcodes. Geoapify`s Geocoding API makes it easy to parse an address and extract the postcode from it. You'll get the parsed address and the structured address.

With API, you can get the postcode from the address string. For example, here is the response that you get for "Rice Ln, Liverpool, L9 1NL, United Kingdom":

API Request URL
https://api.geoapify.com/v1/geocode/search?text=Rice%20Lane%2C%20Liverpool%2C%20L9%201NL%2C%20United%20Kingdom&format=json&apiKey=YOUR_API_KEY
API Result
{
  "results": [
    {
      "country_code": "gb",
      "street": "Rice Lane",
      "country": "United Kingdom",
      "county": "Merseyside",
      "datasource": {
        "sourcename": "openstreetmap",
        "attribution": "© OpenStreetMap contributors",
        "license": "Open Database License",
        "url": "https://www.openstreetmap.org/copyright"
      },
      "state": "England",
      "city": "Liverpool",
      "suburb": "Walton Vale",
      "state_code": "ENG",
      "lon": -2.961697,
      "lat": 53.455278,
      "postcode": "L9 1NL",
      "formatted": "Rice Lane, Liverpool, L9 1NL, United Kingdom",
      "address_line1": "Rice Lane",
      "address_line2": "Liverpool, L9 1NL, United Kingdom",
      ...
    }
  ],
  "query": {
    "text": "Rice Lane, Liverpool, L9 1NL, United Kingdom",
    "parsed": {
      "street": "rice lane",
      "postcode": "l9 1nl",
      "city": "liverpool",
      "country": "united kingdom",
      "expected_type": "street"
    }
  }
}

The returned data includes both the postcode corresponding to the identified address and the originally parsed postcode.

What else do I need to know about postcode formats?

Here are some questions we hear frequently from our customers.

What is the standard postcode format?

The standard postcode format is different from country to country. We recommend checking the postcode format for the country you want to get postcodes for, to make sure your results are accurate.

What is the UK postcode format?

UK Postcodes have both letters and numbers. They're between five and seven characters long and always start with a letter. They follow the pattern: [A-Z]{1,2}[0-9][A-Z0-9]? [0-9][A-Z]{2}.

What is the ZIP code format in the USA?

ZIP codes in the USA have five numbers and no letters - and some have five digits, a hyphen, then four more digits, in this format: ##### or #####-#### (five or nine digits). The first five digits are essential, while the additional four digits offer more precise location information.

What is the German postcode format?

German postcodes have five numbers. The first two numbers show the geographic area, and the last three show the specific area within that.

What is the postcode format in Canada?

Canadian postcodes are alphanumeric and use the format: A1A 1A1, where "A" represents a letter and "1" represents a digit. They always start with a letter.

What is the postcode format in the Netherlands?

The Netherlands uses an alphanumeric postcode system that has four digits followed by two uppercase letters, in this format: 1234 AB. The first two digits show the city and region, the second two digits and the letters show a range of house numbers. The numbers are usually on the same street.

Is there an international postcode format?

No. Every country has its own unique postcode format, so please check the postcode before using!

How do I enter a postcode in the correct format?

To enter a postcode correctly, it helps to know the specific format for the country in question. Some formats use numbers only, some use letters and numbers, and some have a hyphen or a space between different parts of the code. A country's postal service guidelines or an online postcode lookup tool can help you get it right.

What is a postal code regex?

A postal code regex is a regular expression pattern you can use to validate and match postal code formats for a specific country. A regex helps you check that postcodes match the format. For example, a regex for Canadian postal codes would match to the pattern A0A 1B1, where A and B are letters, and 0 and 1 are digits.

Does every country have a postcode system?

Although most countries have a postcodes system, a handful don't. For example, Gibraltar, Hong Kong and Samoa each have one postcode to cover the whole country. Some countries such as Angola, the Bahamas, and Bolivia, don't require a postcode.

Do postcode lengths differ by country?

Yes, there is quite a lot of variation in postcode lengths! The shortest numeric postcode is Afghanistan, at four digits, and the longest is Iran, with ten digits.

If you're looking for help getting the correct postcode format, Geocoding API is here for you. Save time and resources by using it to validate postcodes. Try it today!