Random Postal Code Generator
Generate random postal codes and ZIP codes for testing, for any country or a list of countries, in each country's official format.
Input
Output
Readme
What is a test postal code?
A test postal code is a made-up code that follows a country's postal code format, like 10115 in Germany, K1A 0B1 in Canada, or SW1A 1AA in the United Kingdom. Checkout forms, shipping APIs, and address databases check postal codes against these formats: the number of digits, where letters go, and whether a space or hyphen belongs in the middle. Typing 12345 into a British or Dutch address form fails, so testers need codes that pass these checks for each country they support.
Tool description
Pick one or more countries, or leave the list empty to mix codes from every country that uses postal codes. The tool generates a list of random codes in each country's format, ready to copy or download as a text file. Turn on "Include country code" to write the ISO country code before each postal code, separated by a tab, so the list pastes into a spreadsheet as two columns. The country list shows a sample code next to each name, so you can see the format before you pick it.
Examples
| Country | Format | Example |
|---|---|---|
| United States | 5 digits | 90210 |
| United Kingdom | Area, district, sector | M2 5BQ |
| Canada | Letter-digit pairs | H3Z 2Y7 |
| Netherlands | 4 digits and 2 letters | 1234 AB |
| Japan | 3 and 4 digits | 154-0023 |
| Brazil | 5 and 3 digits | 40301-110 |
| Argentina | Letter, 4 digits, 3 letters | C1070AAM |
Features
- Postal codes for any country, or for a list of countries you pick
- Each country's format, with its spaces, hyphens, and letters
- Optional ISO country code column
- No duplicates within a list
- Copy the list or download it as a text file
- Runs in your browser
How it works
The tool reads each country's postal code pattern from Google's address metadata, the same data Chrome uses to check addresses, through the lib-address package. It builds random codes from these patterns. Where a pattern accepts several spellings, like US codes with or without the ZIP+4 extension, or UK codes with or without the space, the tool writes the country's main format, so all codes in a list look alike.
Tips
- The codes are valid in format, but not every code is assigned to a real place. Use them to test forms and validation, not to look up real addresses.
- Some territories have a single postal code, like Vatican City (
00120) or Gibraltar (GX11 1AA), so a list for them has only one line. - Countries like Hong Kong, Qatar, or the United Arab Emirates have no postal codes, so they aren't in the list. Leave the field empty in your tests for addresses there.
- Codes such as
01001start with a zero, so store them as text, not numbers, or your spreadsheet may drop the leading zero.