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.
If you also work with full international address templates, check Address Formats by Country (JSON).
On this page
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.
Quick Reference by Country
| Country | Common Format | Length | Regex (Validation) | Example |
|---|---|---|---|---|
| United Kingdom | A9 9AA, A99 9AA, AA9A 9AA | 5-7 chars | ^[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}$ | SW1A 1AA |
| United States | NNNNN or NNNNN-NNNN | 5 or 10 chars | ^\d{5}(?:-\d{4})?$ | 10001, 10001-1234 |
| Canada | A1A 1A1 | 7 chars | ^[A-Z]\d[A-Z][ -]?\d[A-Z]\d$ | M5H 2N2 |
| Germany | NNNNN | 5 chars | ^\d{5}$ | 10115 |
| India | NNNNNN | 6 chars | ^\d{6}$ | 110001 |
| Netherlands | NNNN AA | 6-7 chars | ^\d{4}\s?[A-Z]{2}$ | 1234 AB |
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.
For example, EX covers Exeter in the Southwest UK, and several towns around it. EX38 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:
| Postcode | Location | City |
|---|---|---|
| SW1A 1AA | Buckingham Palace | London |
| EH1 1BB | Near Scottish Parliament | Edinburgh |
| L1 8JQ | Close to Liverpool Central railway station | Liverpool |
| B1 1TB | Near Birmingham New Street station | Birmingham |
| CF10 1EP | Close to Cardiff Castle | Cardiff |
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 Code | City | State |
|---|---|---|
| 10001 | New York | NY |
| 90210 | Beverly Hills | CA |
| 60601 | Chicago | IL |
| 20001 | Washington | DC |
| 30301 | Atlanta | GA |
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.
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 Code | Location | Province/Territory |
|---|---|---|
| M5H 2N2 | Near Toronto City Hall | Ontario |
| H3C 3J7 | Near Old Port of Montreal | Quebec |
| V6B 6G1 | Near Vancouver Art Gallery | British Columbia |
| T2P 1J9 | Near Calgary Tower | Alberta |
| R3C 4T7 | Near The Forks, Winnipeg | Manitoba |
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.
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:
| PLZ | City/Town | Region/State |
|---|---|---|
| 10115 | Berlin | Berlin |
| 20095 | Hamburg | Hamburg |
| 80331 | Munich | Bavaria |
| 50667 | Cologne | North Rhine-Westphalia |
| 60311 | Frankfurt | Hesse |
India
India uses a Postal Index Number (PIN), a six-digit code that was introduced in 1972.
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 Code | Location | State/Union Territory |
|---|---|---|
| 110001 | Connaught Place | Delhi |
| 700001 | Kolkata GPO | West Bengal |
| 400001 | Mumbai GPO | Maharashtra |
| 600001 | Chennai GPO | Tamil Nadu |
| 560001 | Bangalore GPO | Karnataka |
How can Regex help developers parse and validate the postcodes?
Utilizing regex (regular expressions) can streamline the way developers extract postcodes.
Use regex in two modes:
- Extraction from text: use a pattern with
/gto find postcode-like strings in longer text. - Input validation: use an anchored pattern (
^...$) to validate a whole input value.
Consider the following examples:
UK Postcodes
- Validation regex (anchored):
/^[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}$/ - Extraction regex (text search):
/\b[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}\b/g - Comment: normalize input to uppercase before validating UK postcodes.
- Find more regex examples here.
US ZIP codes
- Validation regex (anchored):
/^\d{5}(?:-\d{4})?$/ - Extraction regex (text search):
/\b\d{5}(?:-\d{4})?\b/g - Comment: use the anchored pattern for forms where only one ZIP value is expected.
- Find more regex examples here.
German (DE) Postcodes (PLZ)
- Validation regex (anchored):
/^\d{5}$/ - Extraction regex (text search):
/\b\d{5}\b/g - German postcodes are five digits, making validation straightforward.
Canadian Postal Codes
- Validation regex (anchored):
/^[A-Z]\d[A-Z][ -]?\d[A-Z]\d$/ - Extraction regex (text search):
/\b[A-Z]\d[A-Z][ -]?\d[A-Z]\d\b/g - Canadian postal codes follow a specific alphanumeric pattern, alternating letters and numbers.
- Find more regex examples here.
Indian PIN Codes
- Validation regex (anchored):
/^\d{6}$/ - Extraction regex (text search):
/\b\d{6}\b/g - Indian PIN codes are six-digit numbers.
Regex validates format only. It does not guarantee the postcode exists. Use Postcode API or Geocoding API for real postcode verification.
How else can developers parse and validate postcodes?
An API can help you parse and validate postcodes with real location data, not just format checks.
Geocoding API
Use Geoapify's Geocoding API when your input is a full address string and you want to extract structured fields like postcode, city, and street. For high-volume asynchronous processing, use the Batch API.
With an 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":
Discover all the features of Geoapify's Address Lookup, Validation, and Standardization APIs.
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_KEYAPI 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.
Postcode API
Use Postcode API for postcode-first lookups, postcode validation against postcode datasets, and postcode geometry queries. If you need downloadable postcode datasets, see Download Postal Codes by Country.
API Request URL
https://api.geoapify.com/v1/postcode/search?postcode=AB10%201AB&countrycode=gb&apiKey=YOUR_API_KEYAPI Result
{
"results": [
{
"postcode": "AB10 1AB",
"lon": -2.0969,
"lat": 57.1496,
"country": "United Kingdom",
"country_code": "gb",
"state": "Scotland",
"city": "Aberdeen City",
"formatted": "Aberdeen City, AB10 1AB, United Kingdom",
"address_line1": "Aberdeen City",
"address_line2": "AB10 1AB, United Kingdom",
...
}
]
}The response confirms the postcode exists in the dataset and returns structured location details for that postcode.
Learn More
Related resources for postcode lookup, datasets, and global address templates:

Postcode API

Download Postal Codes By Country

Address Formats by Country: JSON Templates to Download
FAQ
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 are 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. Some include ZIP+4 with five digits, a hyphen, and four additional digits (##### or #####-####). The first five digits are essential, while the additional four digits provide 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 it.
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 with four digits followed by two uppercase letters (1234 AB). The first two digits show the city and region, and the remaining digits and letters show a range of house numbers, usually on the same street.
Is there an international postcode format?
No. Every country has its own postcode format.
How do I enter a postcode in the correct format?
Use the country-specific format. Some formats use only numbers, others use letters and numbers, and some include spaces or hyphens. Check official postal service guidelines or use a postcode lookup/validation tool.
What is a postal code regex?
A postal code regex is a regular expression pattern used to validate and match postal code formats for a specific country.
Does every country have a postcode system?
Most countries do, but not all. For example, Gibraltar, Hong Kong, and Samoa each use one postcode for the whole country, while some countries such as Angola, the Bahamas, and Bolivia do not require postcodes.
Do postcode lengths differ by country?
Yes, postcode lengths vary by country. The shortest numeric postcode is Afghanistan (4 digits), and one of the longest is Iran (10 digits).
If you're looking for help getting the correct postcode format, Geoapify APIs are here for you:

