A UK postcode is not a random label. It is a hierarchical geographic key in which every character has a job. SW1A 2AA looks like noise until you know that SW names a part of London, 1A a district inside it, 2 one side of one street, and AA a group of addresses on that side. Roughly 1.8 million postcodes are in live use, and each one covers about 15 households on average — which is why a postcode alone is precise enough to route a delivery.
Every full postcode splits cleanly into two halves with exactly one space between them:
SW1A, M14, EH7.2AA.Worked through on SW1A 2AA:
| Part | Chars | Meaning | Granularity |
|---|---|---|---|
| Area | SW | South-west London postal area | A quadrant of the city / a town |
| District | 1A | District 1, sub-district A (Westminster) | A neighbourhood |
| Sector | 2 | One side of a street within the district | ~a block |
| Unit | AA | One group of addresses | ~15 households |
Some areas are worth recognising on sight: B Birmingham, M Manchester, G Glasgow, L Liverpool, S Sheffield, EH Edinburgh, CF Cardiff, BT Belfast. London is a patchwork of two-letter areas — NW, SE, SW, EC, WC and friends — because one code could never cover the whole city.
Postcodes vary in length because areas and districts do. Six combinations are valid, and all six exist in the wild:
| Format | Example | Where you meet it |
|---|---|---|
| A9 9AA | M1 1AE | Manchester city centre — single-letter area, one digit |
| A9A 9AA | W1A 0AX | BBC Broadcasting House — central London sub-districts |
| A99 9AA | B33 8TH | Birmingham — two-digit districts in bigger areas |
| AA9 9AA | CR0 2YH | Croydon — two-letter area, one digit (district 0 is real) |
| AA9A 9AA | EC1A 1BB | City of London — the fullest outward code |
| AA99 9AA | DN55 1PT | Doncaster — two-letter area, two-digit district |
Two famous ones are worth memorising for the same reason testers memorise edge cases: SW1A 1AA is Buckingham Palace and SW1A 2AA is 10 Downing Street — valid postcodes that belong to single buildings.
W1A), never start with one.0 is legal: W1A 0AX, CR0 2YH.EC1A 1BB fits; EC1A 1MO cannot exist.1ZZ (Ascension's ASCN 1ZZ, the Falklands' FIQQ 1ZZ, Tristan da Cunha's TDCU 1ZZ).JE), Guernsey (GY) and the Isle of Man (IM) issue UK-shaped postcodes under their own administrations. UK-shaped, not UK.Almost every UK-aware validator does the same three steps, and you can run them by hand:
^[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}$ (the six formats above in one line).The failures this catches in real test runs: a missing space (survives step 1, dies at step 3 on strict forms), a full-width digit pasted from a formatted document (looks identical, fails step 2), O typed for 0 (passes shape, fails existence), and the classic — a postcode whose outward code belongs to a different town than the one in the City field.
That last one is why address generators must bind the town and the postcode together: a correct-looking pair that fails the consistency check is worse than an obvious placeholder, because it wastes a debugging cycle looking real.
The UK address generator pairs a real town with its real outward code, then synthesises the inward half in valid format — so the output passes shape checks and town/postcode consistency without verifying a real household; synthetic values can still coincide with a real address. For form testing, address-format learning, and QA fixtures, that combination is the whole point. For the US counterpart — ZIP codes and the five tax-free states — see the five-state guide.
In Royal Mail's canonical form, yes: outward code, one space, inward code. Most form validators normalise first (uppercase, re-insert the space), so a spaceless postcode usually survives — but some strict validators reject it outright, and the space is what makes the two halves readable. Copy postcodes whole rather than retyping them.
Roughly, yes — that is what the outward code is for. B is Birmingham, M Manchester, G Glasgow, L Liverpool, S Sheffield, EH Edinburgh, CF Cardiff, BT Belfast; London is a patchwork of two-letter areas (NW, SE, SW, EC…). Two-letter areas usually name a town or a London quadrant; single letters are the big industrial-era cities.
Six valid formats exist — A9 9AA up to AA99 9AA — because area names run from one letter to two, districts from one digit to two, and dense districts carry an extra sub-district letter. The inward half never varies: always one digit then two letters.
They use UK-shaped postcodes but under their own administrations: JE for Jersey, GY for Guernsey, IM for the Isle of Man. They are Crown Dependencies, not UK addresses — and the Isle of Man is inside the UK VAT area while the Channel Islands are not. On UK forms these postcodes often fail town/postcode consistency checks.