Spain código postal validator
How the código postal format works
- Format
- 5 digits
- Example
- 28013
Things to watch for
- Format-only check — does not confirm the código postal actually exists
- Always exactly 5 digits; the first 2 digits usually match the province number
^[0-9]{5}$A Spanish código postal is the 5-digit postcode Correos uses to route mail, written after the city name — for example 28013 for central Madrid. Anyone validating a shipping address, a checkout form, or a spreadsheet of Spanish customer records needs the code to be the right length and shape before it’s trusted downstream.
Because the code is a plain run of 5 digits, a transposed or dropped digit is easy to miss visually while still looking like a plausible postcode — and since the first two digits carry the province’s official number, a typo there can silently point the address to the wrong province entirely.
How this validator works
This tool checks that the input is exactly 5 digits with no letters, spaces, or punctuation, entirely in your browser — nothing is sent to a server, and there’s no signup required.
What a pass doesn’t tell you
A código postal carries no check digit, so a correctly shaped 5-digit string is the most a client-side check can confirm — not that Correos has actually assigned it to a real district or that it matches the province also entered on a form. Confirming that requires Correos’ own postcode lookup.
Scope: format validation only — not address lookup, province matching, or confirming a code is currently in use.
código postal FAQ
What do the first two digits of a Spanish código postal mean?
They match the official province number — for example 28 for Madrid or 08 for Barcelona, the same two-digit province codes used elsewhere in Spanish public administration. The remaining three digits narrow the code to a specific district, town, or delivery zone within that province.
Why does a Madrid postcode start with a 2 and not an 8, even though it's a large city?
Spain's provinces are numbered largely in alphabetical order of their historical names rather than by size or population, so Madrid's 28 reflects its position in that list, not its importance or geography relative to other cities.
Does a correctly formatted código postal mean it actually exists?
No. This tool only confirms the string is 5 digits — it doesn't check the code against Correos' actual list of assigned districts. Confirming a código postal is real requires Correos' own postcode lookup.