A UK postcode is always made of an outward code and an inward code, with the inward code fixed at three characters: a digit followed by two letters.
The valid formats
- A9 9AA — e.g. M1 1AE
- A99 9AA — e.g. M60 1NW
- AA9 9AA — e.g. CR2 6XH
- AA99 9AA — e.g. DN55 1PT
- A9A 9AA — e.g. W1A 0AX
- AA9A 9AA — e.g. EC1A 1BB
Validation vs verification
Regex can confirm a string looks like a postcode, but it can't tell you whether it's real. A typo like "SW1A 9ZZ" may pass a pattern check yet not exist. To truly verify, check against PAF using an address validation API.
Build it in
Combine format checks with live lookups using our Postcode Lookup API, and read more in the PAF guide.
Frequently asked questions
What is the UK postcode format?
UK postcodes follow one of several patterns combining one or two letters, one or two digits, an optional letter, then a space, a digit and two letters — for example A9 9AA, A99 9AA, AA9 9AA, AA99 9AA, A9A 9AA and AA9A 9AA.
How long is a UK postcode?
UK postcodes are between five and seven characters long including the space, with the inward code always being three characters.
How do you validate a UK postcode?
You can validate the pattern with regex, but the only way to confirm a postcode actually exists is to check it against Royal Mail PAF data via a lookup API.
We'll beat any like-for-like UK address lookup price
Send us your current quote or invoice and we'll come back the same working day with a better price — plus free migration and integration support.
- Beat any like-for-like UK quote, monthly or annual
- Free migration + hands-on integration support
- No setup fees, no lock-in, cancel any time
Ready to get started?
Add Royal Mail PAF-verified UK address lookup to your site in minutes — start free, no card required.
