Random UK Postcode Generator

Generate one random UK postcode or five hundred. Every outward code is a genuine Royal Mail district drawn from 57 post towns across 60 postcode areas; the inward code is generated to the official format rules, so results validate without being live delivery points.

What a UK postcode is

A UK postcode is an alphanumeric code, five to seven characters long, that identifies a group of delivery points. Royal Mail introduced them nationally between 1959 and 1974, and there are now around 1.8 million of them. A full postcode covers about fifteen properties on average, which is precise enough that a postcode plus a house number identifies a single address — the reason UK address lookup works the way it does, and something a US ZIP code cannot do.

Postcodes are a postal routing system first and a geography second. They do not align with county or council boundaries, a postcode area can cross a national border, and the post town in an address is a sorting designation rather than a statement about which town the property is in.

The format: outward and inward codes

Every postcode splits into two halves separated by a single space. The outward code routes mail to the sorting office; the inward code routes it from there to the street.

Outward code
Two to four characters before the space, made of the area and the district: SW1A, M1, CR0, EC1A. This is the half that is geographically meaningful.
Inward code
Always exactly three characters after the space: one digit then two letters, such as 1AA or 3RL. This is the sector digit followed by the unit letters.

Six formats are valid and no others, which is what makes UK postcodes checkable without a database lookup. In the patterns below, A stands for any permitted letter and 9 for any digit; the outward code varies between two and four characters while the inward code is always a digit followed by two letters.

One postcode sits outside all six: GIR 0AA, issued to the National Girobank in Bootle. It is still valid and still catches out validation code that only implements the general rules.

Area, district, sector and unit

The four levels nest, each one narrowing the delivery target further, and each is a prefix of the next. Knowing which level you actually need matters when you store postcodes: an analytics rollup usually wants the district, a delivery-zone rule wants the sector, and only address matching needs the full unit. Taking SW1A 1AA — Buckingham Palace — apart from the outside in:

Area — SW
One or two letters, usually abbreviating a city or a London compass sector. There are 121 postcode areas; the registry behind this generator covers 60 of them.
District — SW1A
The area plus a digit, and occasionally a trailing letter. Around 3,000 exist. This is the level a post town actually serves, and the level the generator draws real codes from.
Sector — SW1A 1
The district plus the first digit of the inward code. Roughly 3,000 delivery points, typically a few streets.
Unit — SW1A 1AA
The full postcode. Around fifteen adjacent delivery points, or a single large recipient — which is what SW1A 1AA itself is.

Why some letters are never used

Not every letter can appear in every position. The exclusions exist because postcodes were designed to be read by early optical character recognition and handwritten by the public, so letters that are easily confused with digits or with each other were removed from the positions where the confusion would matter. Any validator that ignores these rules will accept postcodes that cannot exist.

First position
Q, V and X are never used. A leading Q or O is too easily misread; the set in use is ABCDEFGHIJKLMNOPRSTUWYZ.
Second position
I, J and Z are never used, leaving ABCDEFGHKLMNOPQRSTUVWXY.
Third position (A9A format)
Only ABCDEFGHJKPSTUW may appear.
Fourth position (AA9A format)
Only ABEHMNPRVWXY may appear.
The final two letters
C, I, K, M, O and V never appear in the unit letters, leaving ABDEFGHJLNPQRSTUWXYZ. C and O look like digits and each other; I and one, K and X, M and N, V and U are all confusable in handwriting.

The generator applies all five rules, so every postcode it produces will pass a correctly written UK postcode validator. Whether a validator accepts them is, in practice, a useful test of the validator.

UK postcode compared with US ZIP code

UK postcodeUS ZIP code
Characters5–7, letters and digits, one internal space5 digits, or 9 as ZIP+4
ExampleEC1A 1BB10001
How manyAbout 1.8 million full postcodesAbout 41,000 ZIP codes
PrecisionAround 15 delivery pointsA delivery route, town or city district
Identifies an address?Yes, with a house numberNo, the full street address is needed
StructureArea, district, sector, unitNational area, sectional centre, delivery area
Case and spacingConventionally upper case with one space; both are significant to some validatorsDigits only, no spacing question
ChangesNew districts and units are added as areas developBoundaries are redrawn by USPS as volume shifts

The size difference is the one that matters when porting software: a database column sized for five characters, a numeric column type, or a regex of ^\d{5}$ will all reject valid UK postcodes.

Frequently asked questions

Are these real postcodes?

The outward code — the half before the space — is a real Royal Mail postcode district taken from the registry, so the area, district and post town are genuine. The inward code after the space is generated to the official format rules. The result is a structurally valid postcode that is not a live delivery point, which is exactly what you want in test data: it validates, but it cannot be mistaken for a real address.

Will these pass postcode validation?

Yes, if the validator implements the published rules. Every generated postcode uses one of the six valid formats and respects the excluded letters at each position. A regex or library that follows the UK Government Data Standards Catalogue definition will accept them. A lookup against Royal Mail’s Postcode Address File will not find them, because they are not assigned.

Can I generate postcodes for a specific city or region?

Yes. Filter by country — England, Scotland, Wales or Northern Ireland — or narrow to a single post town, and every postcode will come from a district that town genuinely serves. The result table shows the area, district, sector and format for each one.

How many can I generate at once?

Up to 500 in the browser, and up to 1,000 per request through the free REST API at /api/v1/postcodes/random. No API key or sign-up is required.

What is the difference between a postcode area, district, sector and unit?

They nest from broad to narrow. In SW1A 1AA, the area is SW, the district is SW1A, the sector is SW1A 1, and the unit is the whole postcode. The area routes to a region, the district to a sorting office, the sector to a few streets, and the unit to about fifteen delivery points.

Why do some postcodes have a letter in the middle of the outward code?

Those are the A9A and AA9A formats, used where a district needed subdividing after the original allocation. They are concentrated in central London — W1A, EC1A, SW1A — and they are the formats most often broken by validation code that assumes the outward code ends in a digit.

Is GIR 0AA a real postcode?

Yes. It was issued to the National Girobank in Bootle and remains valid. It fits none of the six standard formats, so it has to be special-cased. It is a good test of whether a validator was written from the specification or from a guess.

Can I use these commercially?

Yes, with no attribution required — in commercial software, open-source projects, QA pipelines and staging databases. They must not be used to imply a real address or for identity verification.

Related tools

Postcodes are generated on demand and never stored. They are for software testing and development only, and must not be used to imply a real address or for identity verification.