The UK Postcode Format Explained: Areas, Districts, Sectors and Units

Postcodes · August 2026 · 8 min read

A complete breakdown of how a UK postcode is built, the six permitted formats, the letters that can never appear, and the edge cases that break naive validation.

A UK postcode is not a number. It is a hierarchical alphanumeric code with a strict grammar, and almost every validation bug in a UK address form comes from treating it as free text.

The two halves

Every postcode has two parts separated by a single space:


SW1A 1AA
└──┘ └─┘
outward inward

The outward code gets a letter to the right sorting office. It is made of the postcode area (one or two letters, such as M for Manchester or EH for Edinburgh) followed by the district (one or two digits, or a digit and a letter).

The inward code completes delivery. It is always exactly one digit — the sector — followed by two letters — the unit. The inward code is always three characters. That single fact gives you the most reliable formatting rule there is: the space always goes three characters from the end.

The six permitted formats

Writing A for a letter and 9 for a digit, only these shapes exist:

If your validator only accepts AA9 9AA and AA99 9AA, it will reject every address in the City of London, most of the West End, and every single-letter area — Birmingham, Manchester, Liverpool, Glasgow, Sheffield and all eight London areas.

The letters that never appear

This is where most home-grown regular expressions fail. The system deliberately excludes letters that are easily confused when read by machine or by hand:

  • Position 1 never uses Q, V or X.
  • Position 2 (the second letter of a two-letter area) never uses I, J or Z.
  • Position 3, when it is a letter (the A9A shape), is one of A, B, C, D, E, F, G, H, J, K, P, S, T, U or W.
  • Position 4, when it is a letter (the AA9A shape), is one of A, B, E, H, M, N, P, R, V, W, X or Y.
  • The final two letters never use C, I, K, M, O or V.

So M1 1AC looks plausible and is not a valid postcode, because C cannot appear in the unit.

A validator that gets it right


const UNIT = 'ABDEFGHJLNPQRSTUWXYZ';   // no C, I, K, M, O, V
const FIRST = 'ABCDEFGHIJKLMNOPRSTUWYZ'; // no Q, V, X
const SECOND = 'ABCDEFGHKLMNOPQRSTUVWXY'; // no I, J, Z
const THIRD = 'ABCDEFGHJKPSTUW';
const FOURTH = 'ABEHMNPRVWXY';

const POSTCODE = new RegExp(
  '^(?:GIR ?0AA|(?:' +
    `[${FIRST}](?:[0-9][0-9]?|[0-9][${THIRD}])` + '|' +
    `[${FIRST}][${SECOND}](?:[0-9][0-9]?|[0-9][${FOURTH}])` +
  `) ?[0-9][${UNIT}]{2})

  
    
    

    
    

    The UK Postcode Format Explained: Areas, Districts, Sectors and Units | UK Random Address Generator
    
    
    

    
    
    
    
    
    
    
    

    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
  
  
  
  
    ,
  'i'
);

const normalise = (value) => value.toUpperCase().replace(/\s+/g, '');
const format = (value) => {
  const compact = normalise(value);
  return compact.length < 5 ? compact : `${compact.slice(0, -3)} ${compact.slice(-3)}`;
};

const isValid = (value) => POSTCODE.test(format(normalise(value)));

Always normalise before you compare. Users type sw1a1aa, SW1A 1AA and Sw1a 1aa, and all three are the same postcode.

Edge cases worth knowing

GIR 0AA is a genuine postcode with a three-letter outward code. It was allocated to the National Girobank in Bootle. It matches none of the six formats and must be special-cased, which is why it appears explicitly in the regular expression above.

BFPO addresses serve British Forces personnel overseas. They historically used BFPO 1234 with no postcode at all; the BF1 postcode area now provides conventional postcodes for the same purpose. A form that requires a standard postcode will lock out service families.

Non-geographic areas exist for organisations that receive very high volumes of mail. BX is used by banks and government departments, and codes such as GIR 0AA or large-user codes like M60 in Manchester do not correspond to a street address you can visit.

Northern Ireland is entirely covered by the BT area, from BT1 in central Belfast to BT94. It is the only postcode area covering a whole country.

Areas, districts, sectors and units in practice

Each level of the hierarchy is useful for something different:

  • Area (M) — roughly a city and its hinterland. Useful for coarse regional grouping.
  • District (M20) — around 3,000 delivery points. Commonly used for pricing, delivery zones and analytics.
  • Sector (M20 8) — a few hundred addresses. Used for route planning and demographic reporting.
  • Unit (M20 8DP) — typically 15 addresses, often one side of a street. This is the level a full postcode identifies.

A postcode plus a house number is therefore enough to identify a UK property uniquely in almost every case, which is why UK address forms use "postcode lookup" rather than asking for the full address up front.

Testing your validation

Use these cases as a starting point. Valid: SW1A 1AA, M1 1AE, B33 8TH, CR2 6XH, DN55 1PT, EC1A 1BB, W1A 0AX, GIR 0AA, BT1 1AA, G1 1XW, CF10 1EP. Invalid: QW1A 1AA (Q first), SI1 1AA (I second), M1 1AC (C in the unit), SW1A 1AAA (too long), 12345 (not a postcode at all).

You can generate as many structurally valid examples as you need with the UK postcode generator, or check a specific one with the postcode validator.

More guides