United Kingdom postcode validator

How the postcode format works

Format
1-2 letters + digit + optional letter/digit + digit + 2 letters
Example
SW1A1AA

Things to watch for

  • Format-only check — does not confirm the postcode actually exists
  • Existence lookup requires Royal Mail PAF or the ONS Postcode Directory (ONSPD)
  • Space before the last 3 characters is optional here
Regex for postcode
^[A-Z]{1,2}[0-9][A-Z0-9]?[0-9][A-Z]{2}$

A UK postcode is the address code Royal Mail uses to route mail to a specific building or small group of properties, written in two parts — for example SW1A 1AA. Anyone validating a shipping address, cleaning a customer database, or checking a form input before it’s submitted needs to know the postcode is at least correctly shaped before it’s used downstream.

Catching a malformed postcode early matters because the format is rigid but easy to get subtly wrong: the outward code runs one or two letters, then a digit, then an optional extra letter or digit, while the inward code is always a single digit followed by two letters. A character in the wrong slot, or a missing final letter, is cheaper to catch at data entry than after a shipment goes out or a checkout form fails silently.

How this validator works

This tool checks the outward code (1-2 letters, a digit, and an optional extra letter or digit) followed by the inward code (a digit and 2 letters), entirely in your browser. Nothing is sent to a server, there’s no signup, and it accepts the postcode with or without the customary space before the last three characters.

What a pass doesn’t tell you

UK postcodes don’t carry a check digit the way a VAT number or bank account does, so a correctly shaped postcode is the most a client-side tool can confirm — not that Royal Mail has assigned it to an address. Confirming a postcode is real, and seeing which addresses sit inside it, requires Royal Mail’s Postcode Address File (PAF) or the ONS Postcode Directory (ONSPD).

Scope: this page and tool cover UK postcode format validation only — not address lookup, delivery-point matching, or confirming a postcode is currently in use, none of which a format check alone can tell you.

Content last reviewed 2026-07-07.

postcode FAQ

What are the two halves of a UK postcode called?

The first part is the outward code (an area and district, e.g. 'SW1A' in SW1A 1AA), which routes mail to a sorting office; the second is the inward code (a sector and unit, e.g. '1AA'), which narrows delivery down to a specific street or building.

Does a correctly formatted postcode mean it actually exists?

No. This tool only confirms the string matches the outward-plus-inward pattern Royal Mail uses — it doesn't check the postcode against a real address list. Confirming a postcode exists and seeing the addresses inside it requires Royal Mail's Postcode Address File (PAF) or the ONS Postcode Directory.

Do I need to type the space before the last three characters?

No — this validator accepts the postcode with or without the space (e.g. 'SW1A1AA' or 'SW1A 1AA'). The space is a formatting convention, not part of the postcode's actual identity.

← More postcode validators