UK Postcode Format Checker Widget
Let visitors or staff check that a UK postcode is written in a valid shape before it goes into a form or spreadsheet - one at a time or a pasted list of up to 200 - with the corrected spelling and a plain explanation of each part, and a clear reminder that a valid format is not proof the postcode exists.
Live preview
Under the widget on your page: Powered by A2Z Tools
Embed code
<iframe src="https://a2z.tools/embed/w/uk-postcode-checker" title="UK Postcode Format Checker by A2Z Tools" width="100%" height="640" style="border:0;width:100%" loading="lazy" allow="clipboard-write"></iframe>
A plain iframe. Works everywhere, including site builders that strip scripts. Adjust height if your content needs more room.
<div data-a2z-widget="uk-postcode-checker" data-height="640"></div> <script async src="https://a2z.tools/embed.js"></script>
Adds a small script (what it does) that sizes the widget to fit its content, loads it lazily and keeps it isolated from your page's CSS.
Works with
How it works
The input is upper-cased and every space removed, then the last three characters become the inward code and the rest the outward code, and one space is put between them - so "po155rr" becomes PO15 5RR. The inward code must be a digit followed by two letters. The outward code must match one of the six documented shapes, A9, A99, A9A, AA9, AA99 or AA9A, where a two-letter area never has I or Z as its second letter - the BS 7666 pattern the Home Office publishes in its bulk data schema. A valid result is split the way ONS describes postal geography: the area is the leading letters (PO), the district is the whole outward code (PO15), the sector adds the inward digit (PO15 5) and the unit is the full postcode. Special cases are named: GIR 0AA, BF1 postcodes and "BFPO 52"-style numbers for British Forces mail, the Falklands' FIQQ 1ZZ, St Helena's STHL 1ZZ and Gibraltar's GX11 1AA.
Method
- Normalise: upper-case, remove all whitespace; outward = all but the last 3 characters, inward = the last 3
- Inward code: digit + two letters (9AA)
- Outward code: A9 | A99 | A9A | AA9 | AA99 | AA9A, second letter of AA in A-H or J-Y
- Area = leading letters; district = outward; sector = outward + first inward digit; unit = outward + space + inward
Worked examples
Fix spacing and case
Inputs: po155rr
Result: Valid UK postcode format: PO15 5RR - area PO, district PO15, sector PO15 5
Inward code 5RR is a digit and two letters; outward PO15 is the AA99 shape.
Missing a character
Inputs: SW1A1A
Result: Not a valid UK postcode format - the inward code must be a digit then two letters
The last three characters are A1A.
Forces mail
Inputs: BFPO 52
Result: Not a postcode - BFPO number 52; BFPO addresses also have a BF1 postcode
GOV.UK lists BF1 2AR for BFPO 52 (Gibraltar).
Limitations
- Format only: no address or existence lookup, so terminated or never-issued postcodes that fit the pattern are reported as valid.
- Position-by-position letter restrictions beyond the BS 7666 pattern (for example letters unused in the first position) are not applied.
- Overseas-territory codes are limited to the three verified on GOV.UK; Crown Dependency postcodes (GY, JE, IM) are checked by the normal pattern.
Where publishers use it
- An ecommerce checkout help page where customers check why their postcode is rejected
- A CRM or mailing-list cleanup guide: paste a column of postcodes and copy back the correctly spaced ones
- A data-protection or GIS tutorial explaining postcode area, district, sector and unit
- A charity's volunteer sign-up page reminding people of the format before submitting
- A forces families' site explaining BFPO numbers versus BF1 postcodes
Questions
Does a valid result mean the postcode exists?
No. The checker tests the shape only and makes no lookup: a code can fit A9 9AA or AA99 9AA and still never have been issued, or have been retired. Only an address lookup against Royal Mail or ONS data can confirm a postcode is real and in use.
What are the outward and inward codes?
The outward code (2-4 characters, e.g. PO15) gets mail to the right delivery office; the inward code (always 3 characters, e.g. 5RR) narrows it to a street or group of about 15 addresses. ONS counts roughly 1.79 million live unit postcodes.
Why is the space important?
The inward code is always the last three characters, so the space can be restored from any spelling: "sw1a1aa" becomes SW1A 1AA. Storing the single-space form makes matching and sorting reliable.
What about BFPO addresses?
British Forces mail uses a BFPO number (for example BFPO 52 for Gibraltar), and GOV.UK also lists a BF1 postcode for each - BF1 2AR for BFPO 52. The checker explains that "BFPO 52" is a number, not a postcode, and accepts BF1 postcodes.
Do overseas territories have postcodes?
Some do, in UK style: the Falkland Islands use FIQQ 1ZZ, St Helena STHL 1ZZ and Gibraltar GX11 1AA. These are accepted and labelled; other territories' codes are not included because they could not be verified from an official source.
Sources
- Postal geography - Office for National Statistics . Outward code of 2-4 characters and inward code of 3; postcode area, district, sector and unit; PO15 5RR example. Checked 2026-10-01.
- Bulk data transfer toolkit: XML schema (BulkDataCommon-v2.1.xsd) - Home Office (GOV.UK) . UK postcode pattern "corresponding to BS7666": GIR 0AA and the outward shapes with the second letter limited to A-H and J-Y. Checked 2026-10-01.
- Send mail with the British Forces Post Office (BFPO) - Ministry of Defence (GOV.UK) . BFPO numbers and their BF1 postcodes, e.g. BFPO 52 Gibraltar = BF1 2AR. Checked 2026-10-01.
- Governor's Office Stanley; Governor's Office St Helena; Office of the Governor Gibraltar - Foreign, Commonwealth & Development Office (GOV.UK) . Office addresses with the postcodes FIQQ 1ZZ, STHL 1ZZ and GX11 1AA. Checked 2026-10-01.
Cite or recommend this tool
If you reference this tool in an article, course or documentation, these formats are ready to copy. They are optional - nothing is added to your site unless you paste it.
A2Z Tools UK Postcode Format Checker https://a2z.tools/embed/uk-postcode-checker
<a href="https://a2z.tools/embed/uk-postcode-checker">A2Z Tools UK Postcode Format Checker</a>
[A2Z Tools UK Postcode Format Checker](https://a2z.tools/embed/uk-postcode-checker)
UK Postcode Format Checker by A2Z Tools - https://a2z.tools/embed/uk-postcode-checker
Related widgets
-
Next and upcoming UK bank holidays for England and Wales, Scotland or Northern Ireland, from GOV.UK.
-
Add VAT to a net price or extract it from a gross price, at a UK rate or any rate you type.
-
US-style sales tax from the state and local rates you enter, or the tax hidden in a tax-inclusive total.
-
Profit, gross margin and markup from cost and price - or the price for a target margin.
-
Selling price from cost plus markup, or work back to the cost or the markup you applied.
-
Sale price and savings, including stacked discounts and sales tax on the reduced price.