UK Postcodes Formatting Rules


The formatting rules for postcodes appear complex at first, but are in fact straightforward. Essentially, every postcode consists of two elements, separated by a space. The outward part of the code comes first, then the space, then the inward part of the code. So, in the postcode SW1A 1AA (Buckingham Palace), SW1A is the outward code and 1AA is the inward code.

Generally the outward code consists of either one or two letters, followed by either one or two digits. The letters represent the 124 UK postal areas (SW, for example, is covering part of southwest London), while the digits indicate the districts within the areas. Most of the postal areas have two letters, but eight of them are represented by a single letter (e.g. G for Glasgow).

Outward rules:

  • Postal areas which have only single-digit districts: BR, FY, GY, HA, HD, HG, HR, HS, HX, JE, LD, SM, SR, WC, WN, ZE.
  • Postal areas which have only double-digit districts: AB, LL, SO.
  • Only a few areas have a district 0 (zero): BL, CM, CR, FY, HA, PR, SL, SS; none of these areas also has a district 10, and district 0 is sometimes treated as though it were the tenth district in the area and sorted after district 9.
  • In central London, some overcrowded single-digit postcode districts have been further divided by inserting a letter after the digit and before the space. This applies to all of EC1–EC4 (but not EC50), SW1, W1, WC1 and WC2; and to part of E1 (E1W), N1 (N1C and N1P), NW1 (NW1W) and SE1 (SE1P). All letters in the set ABCDEFGHJKMNPRSTUVWXY are currently used as the trailing letter in one or more divided districts, which excludes the five letters ILOQZ.

Outward rules:

  • The first character after the space is a digit from 0 to 9 which determines the postcode sector. Originally, Royal Mail sorted sector 0 after 9 instead of before 1, effectively treating it as the 10th not the 1st sector label.
  • The final two letters form the postcode unit. The letters in the inward code are restricted to the set ABDEFGHJLNPQRSTUWXYZ, which excludes the six letters CIKMOV so as not to resemble digits or each other when hand-written.

Each postcode unit generally represents a street, part of a street, or a single address.

Component Part Example Live codes Terminated codes Other codes Total
postcode area out code YO 124 0 3 127
postcode district out code YO31 2,971 103 4 3,078
postcode sector in code YO31 1 10,631 1,071 4 11,706
postcode unit in code YO31 1EB 1,762,464 650,417 4 2,412,885
Postcode Addresses approx. 27,000,000

The letters in the outward code give some clue to its approximate geographical location. For example, L indicates Liverpool, EH indicates Edinburgh and AB indicates Aberdeen; see List of postcode areas in the United Kingdom for a full list. Most postcode areas outside London cover many towns and localities beyond the city after which they are named. For instance, although BT indicates Belfast, it covers the whole of Northern Ireland.

Unlike with US zip codes, you cannot download a simple text file containing all known postcodes for use in validation routines. The official Postcode Address File (PAF) contains around 27 million codes, and is subject to strict copyright and licensing controls. The only practical way to access it is by purchasing specialised address management software, and this is inevitably an expensive option. However, based on formatting rules above, we can at least check if a provided postcode follow these roles by using a computer program. -- see Validating UK Postcodes