If you've ever built an international address form, you know that "zip code" doesn't mean the same thing in every country. Postal code formats vary wildly: the US uses 5 digits, the UK mixes letters and numbers, Canada has alphanumeric codes with a space in the middle, and some countries don't use postal codes at all. This guide is a complete reference to postal code formats around the world, with validation patterns and a programmatic source you can use.
Why Postal Code Validation Is Hard
The biggest mistake developers make is writing a single regex like /^\d{5}$/ and applying it globally. That works perfectly for US addresses and breaks immediately for everywhere else.
The reality is:
- About 60 countries use a 5-digit numeric format (US, France, Germany, Spain, Italy, Mexico, Turkey, etc.)
- About 30 countries use 4-digit numeric (Australia, Belgium, Switzerland, Norway, etc.)
- About 20 countries use alphanumeric formats (UK, Canada, Netherlands, Argentina, etc.)
- About 20 countries use 6 or more digits (India PIN, China, Russia)
- About 10 countries have no postal code system at all (Hong Kong, UAE, Ireland traditionally — although Ireland now has Eircode)
Postal Code Formats by Country
Here's a reference table for the most common formats:
| Country | ISO | Format | Example | Regex |
|---|---|---|---|---|
| United States | US | 5 digits, optional +4 | 94103 or 94103-1234 | ^\d{5}(-\d{4})?$ |
| United Kingdom | GB | Alphanumeric with space | SW1A 1AA | ^[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}$ |
| Canada | CA | A1A 1A1 (letter-digit-letter) | K1A 0B1 | ^[A-Z]\d[A-Z] ?\d[A-Z]\d$ |
| Germany | DE | 5 digits | 10115 | ^\d{5}$ |
| France | FR | 5 digits | 75001 | ^\d{5}$ |
| Spain | ES | 5 digits | 28001 | ^\d{5}$ |
| Italy | IT | 5 digits (CAP) | 00100 | ^\d{5}$ |
| Netherlands | NL | 4 digits + 2 letters | 1011 AB | ^\d{4} ?[A-Z]{2}$ |
| Belgium | BE | 4 digits | 1000 | ^\d{4}$ |
| Switzerland | CH | 4 digits | 8001 | ^\d{4}$ |
| Austria | AT | 4 digits | 1010 | ^\d{4}$ |
| Australia | AU | 4 digits | 2000 | ^\d{4}$ |
| New Zealand | NZ | 4 digits | 6011 | ^\d{4}$ |
| Brazil | BR | 8 digits with hyphen (CEP) | 01310-100 | ^\d{5}-?\d{3}$ |
| Mexico | MX | 5 digits | 06600 | ^\d{5}$ |
| Japan | JP | 7 digits with hyphen | 100-0001 | ^\d{3}-?\d{4}$ |
| India | IN | 6 digits (PIN) | 110001 | ^\d{6}$ |
| China | CN | 6 digits | 100000 | ^\d{6}$ |
| Russia | RU | 6 digits | 101000 | ^\d{6}$ |
| South Korea | KR | 5 digits | 04524 | ^\d{5}$ |
| Argentina | AR | Letter + 4 digits + 3 letters (CPA) | C1425CLA | ^[A-Z]\d{4}[A-Z]{3}$ |
| Sweden | SE | 5 digits with space | 113 30 | ^\d{3} ?\d{2}$ |
| Norway | NO | 4 digits | 0150 | ^\d{4}$ |
| Poland | PL | 2 digits + hyphen + 3 digits | 00-001 | ^\d{2}-\d{3}$ |
| Portugal | PT | 4 digits + hyphen + 3 digits | 1000-001 | ^\d{4}-\d{3}$ |
Countries Without Postal Codes
Some countries do not use postal codes at all. You should not require a postal code for addresses in:
- Hong Kong
- United Arab Emirates (uses P.O. Box system instead)
- Qatar (P.O. Box system)
- Yemen
- Jamaica (no formal system; some districts use codes)
- Most Pacific Island states (Fiji, Tonga, Samoa, Vanuatu)
- Several African countries (Angola, Burkina Faso, Côte d'Ivoire, etc.)
Your address form should make the postal code field optional or hidden when one of these countries is selected. Forcing users to enter "00000" or "N/A" leads to bad data and form abandonment.
Special Cases You Should Know
UK postcodes are highly structured. A UK postcode like "SW1A 1AA" encodes the area (SW), district (1A), sector (1) and unit (AA). The first half (the "outward" code) identifies the post town and the second half identifies the delivery point. UK postcodes can have variable-length outward codes.
Canadian postal codes use a checksum-like alternation. They follow A1A 1A1 where A is a letter and 1 is a digit. The first letter identifies a province or sub-region (K = Eastern Ontario, M = Toronto, V = British Columbia).
Brazilian CEP includes a hyphen. The Brazilian Código de Endereçamento Postal is 8 digits commonly written with a hyphen after the 5th: "01310-100". Both formats (with and without hyphen) should be accepted.
Argentinian CPA replaced the older format. Argentina switched from a 4-digit numeric code to the alphanumeric CPA (Código Postal Argentino) in 1999. Some legacy systems still use the old 4-digit format, but new applications should accept the CPA.
Irish Eircode is relatively new. Ireland introduced Eircode in 2014. Before that, the Republic of Ireland had no postal code system. Eircode is "Routing Key + Unique Identifier" — for example "D02 X285" identifies a specific address, not just an area.
Fetching Postal Codes via REST API
Country Data API provides postal code data through the /v1/zipcode endpoints. To get all zip codes in a country:
GET https://api.countrydataapi.com/v1/zipcode/by-country?country=US
Authorization: Bearer YOUR_API_KEY
To get zip codes for a specific state:
GET https://api.countrydataapi.com/v1/zipcode/by-state?country=US&state=CA
Authorization: Bearer YOUR_API_KEY
To look up which country a zip code belongs to:
GET https://api.countrydataapi.com/v1/countries/by-zipcode?zipcode=10115
Authorization: Bearer YOUR_API_KEY
See the zip code endpoint documentation for full details.
Best Practices for Address Forms
- Make the postal code field dynamic. Show or hide it based on the selected country, and update the regex/placeholder accordingly.
- Auto-format on input. Insert the hyphen in Canadian or Brazilian postcodes automatically.
- Don't validate too aggressively. Accept common variations (with or without spaces, uppercase or lowercase) and normalize on the server.
- Use the API to autocomplete the city. When the user enters a postal code, query
/v1/countries/by-zipcodeto verify and pre-fill the city/state.
Get Started
Start integrating postal code data into your application: create a free account at CountryDataAPI. Plans start at $9.99/month with 10,000 monthly requests including 500,000+ postal codes worldwide.
See also the related guides on ISO country codes and address form validation.

