A random postal code generator produces postal codes in the correct format for the UK, Canada, Australia, Japan and New Zealand. Each code follows that country’s real pattern, such as SW1A 1AA or K1A 0B1, so it passes form validation. It is format-valid only and may not belong to a real street.
Last updated: 26 October 2026
T7 3SDN3 5PNB9 7LNN25 2ELNW1V 0NXF9 6XGYX3 4GZW4U 7QSM9G 7UQNW1B 6GNSW1N 7XJMV2 3XJ
Showing United Kingdom postcodes in the correct format. A generated code may not be assigned to a real street.
How to generate a random postal code
Select a country, set how many codes you want from 1 to 500, and press Generate. For Japan you can turn on the postal mark, and the compact option strips the space or hyphen for fields that expect digits and letters only. No duplicates keeps a batch unique. Copy a single code, copy the list, or download it as CSV or JSON with the country in its own column. Codes are created in your browser, so nothing you generate leaves your device.

Postal code formats by country
Each country builds its code differently, and a validator written for one rarely accepts another. The table gives the format, a valid example and a validation pattern you can copy into your own tests. The patterns check shape only. They accept every code that fits the format, whether or not the code is in use.
| Country | Format | Example | Validation pattern |
|---|---|---|---|
| United Kingdom | Outward code + space + inward code (A9 9AA, A99 9AA, A9A 9AA, AA9 9AA, AA99 9AA, AA9A 9AA) | SW1A 1AA | ^[A-Z]{1,2}[0-9][A-Z0-9]? ?[0-9][ABD-HJLNP-UW-Z]{2}$ |
| Canada | Letter-digit-letter, space, digit-letter-digit; D F I O Q U never used | K1A 0B1 | ^[ABCEGHJ-NPRSTVXY][0-9][ABCEGHJ-NPRSTV-Z] ?[0-9][ABCEGHJ-NPRSTV-Z][0-9]$ |
| Australia | Four digits | 2000 | ^[0-9]{4}$ |
| Japan | Three digits, hyphen, four digits, optional postal mark | 〒100-0001 | ^〒?[0-9]{3}-?[0-9]{4}$ |
| New Zealand | Four digits | 6011 | ^[0-9]{4}$ |
Random UK postcode and Canadian postal code rules
UK postcodes have two halves. The outward code names the postcode area and district, and the inward code, always a digit followed by two letters, narrows it to a group of addresses. Six layouts exist, from a single letter and digit up to two letters, a digit and a trailing letter. Some letters are barred in some positions: Q, V and X never start a postcode, and C, I, K, M, O and V are not used in the final two letters. The generator respects those rules so its output survives a strict validator.
A Canadian postal code alternates letters and digits as A1A 1A1. The letters D, F, I, O, Q and U are never used because they are easily confused with digits or other letters, and W and Z cannot begin a code. Australian and New Zealand codes are four digits, and a Japanese code is seven digits written with a hyphen after the third.
Format-valid versus real postal codes
Passing a pattern and being a real, deliverable code are different things. A code can fit the format and still belong to no street, and a real code can fail a badly written pattern. Use generated codes for testing how your form behaves with each country’s shape. Look-ups of real codes belong to the national postal operator. For background on how a code relates to a place, is zip code based on city? covers the US system.

Bulk postal codes: generate, copy and export
For a large test file, set the count to 500 and generate once. Use Copy all to paste the list straight into a spreadsheet or a script, or download CSV for a table with the code and the country in separate columns, or JSON for fixtures. Turn on no duplicates when a column must be unique, and the compact option when your import expects values without spaces or hyphens. If the same test file needs a network column too, a random ip address generator fills it in the same way.
Postal code vs ZIP code
ZIP code is the name used in the United States. Elsewhere the same idea is called a postal code, a postcode or a PIN code. A US ZIP code is five digits with an optional four-digit extension, which is much simpler than the letter-and-digit patterns above. The US side is covered by the ZIP code tool on this site.
Random postal code generator FAQ
Are the generated postal codes real?
They follow the real format of each country, but a generated code may not be assigned to any street. Format-valid means a validator will accept it; it does not mean mail can be delivered there.
How is a UK postcode built?
A UK postcode has an outward part and an inward part separated by a space, for example SW1A 1AA. The outward part is one or two letters followed by a digit and sometimes a digit or letter. The inward part is one digit and two letters, and the letters C, I, K, M, O and V are never used in it.
Which letters does a Canadian postal code avoid?
Canadian postal codes follow the pattern A1A 1A1. The letters D, F, I, O, Q and U are never used, and W and Z never start a code. A code that breaks these rules will fail most validators.
Why does Japan show a postal mark?
Japanese postal codes are seven digits written as 123-4567, often with the postal mark before them. The mark is optional in the tool, and the compact option removes the hyphen for fields that want digits only.