Part of a Data Solution
- Explore →
Postal Codes Solution
Every worldwide postal-code dataset in one bundle — the ultimate global reference for precise postal codes.
Premium
You're viewing a free sample
Get the complete dataset — all rows and files — delivered instantly after checkout, with lifetime access to the latest version.
- Secure checkout via Stripe
- Instant download after payment
- Lifetime access to the latest version
- Creative Commons Attribution 4.0 International license
API Access
Access dataset files directly from scripts, code, or AI agents.
Browse dataset files
API Access
Access dataset files directly from scripts, code, or AI agents.
Each file has a stable URL (r-link) that you can use directly in scripts, apps, or AI agents. These URLs are permanent and safe to hardcode.
Start with these files — they give you everything you need to understand and access the dataset.
- 1. Fetch datapackage.yaml to inspect schema and resources
- 2. Download data resources listed in datapackage.yaml
- 3. Read README.md for full context
Data Files
postal-codes-es-sample
| Field | Type | Description | Constraints | Title |
|---|---|---|---|---|
| country_code | string | ISO 3166-1 alpha-2 country code — always `ES` | { "pattern": "^ES$", "required": true } | Country Code |
| postal_code | string | Five-digit Spanish postal code (código postal). Leading zeros are significant: the first two digits are the INE province code 01-52. | { "pattern": "^(0[1-9]|[1-4]\\d|5[0-2])\\d{3}$", "required": true } | Postal Code |
| place_name | string | Municipality name in natural reading order | { "required": true } | Place Name |
| admin_name1 | string | Autonomous community (comunidad autónoma) | { "required": true } | Administrative Name 1 |
| admin_code1 | string | ISO 3166-2:ES autonomous-community code, ES- prefix stripped | { "pattern": "^[A-Z]{2}$", "required": true } | Administrative Code 1 |
| admin_name2 | string | Province (provincia) | { "required": true } | Administrative Name 2 |
| admin_code2 | string | INE province code (CPRO), 01-52 | { "pattern": "^\\d{2}$", "required": true } | Administrative Code 2 |
| admin_name3 | string | Municipality (municipio) | { "required": true } | Administrative Name 3 |
| admin_code3 | string | INE municipality code (CPRO+CMUN), five digits | { "pattern": "^\\d{5}$", "required": true } | Administrative Code 3 |
| latitude | number | Representative latitude for the postal code, WGS84 / EPSG:4326, decimal degrees, 5 dp | Latitude | |
| longitude | number | Representative longitude for the postal code, WGS84 / EPSG:4326, decimal degrees, 5 dp | Longitude | |
| accuracy | string | Granularity of the coordinate. `POSTAL_CODE` = a point resolved for this specific postal code, not a municipality centroid. `MUNICIPALITY` = a PO-box code with no point of its own: the median of the per-code points in its municipality. Empty where no point exists. | Accuracy | |
| alternative_city_name | string | Pipe-separated aliases: localities inside the municipality, and the municipality's other official-language or register name form | Alternative City Name |
Download
Download sample CSVAbout
- Last updated
- 6 October 2026
- Total rows
- 100
- Format
- CSV
- File size
- 14.6 kB
- Sources
- CartoCiudad, Instituto Geografico Nacional / CNIG (Obra derivada de CartoCiudad 2026 CC-BY 4.0 scne.es) - postal code to municipality relations and per-postal-code coordinates
- Relacion de municipios y sus codigos por provincias, Instituto Nacional de Estadistica (INE), updated 2026-01-01 - Elaboracion propia con datos extraidos del sitio web del INE; the INE neither participates in nor endorses this dataset
- GeoNames (CC BY 4.0) - independent cross-check and locality names; see README.md for the multi-municipality, cross-province-routing and accuracy-tier notes
About this dataset
Postal Codes Dataset for Spain (ES)
This dataset lists Spanish postal codes (códigos postales) across every autonomous community, every province and every municipality. Rows carry the INE administrative codes at all three tiers and a coordinate.
Column definitions, row count, size and last-updated date are in datapackage.yaml.
Data Sources
- Obra derivada de CartoCiudad 2026 CC-BY 4.0 scne.es: Instituto Geográfico Nacional / CNIG, under Orden FOM/2807/2015, CC BY 4.0. Provides the postal code to municipality relations and the postal-code coordinates.
- Elaboración propia con datos extraídos del sitio web del INE: www.ine.es: Relación de municipios y sus códigos por provincias (update date in ATTRIBUTION.txt). Provides the municipality, province and community reference. The INE neither participates in nor endorses this dataset.
- © GeoNames, CC BY 4.0: independent cross-check, municipalities the CartoCiudad layer misses, and locality names.
Changes made to the source data: postal code to municipality relations deduplicated and joined to the INE municipality register; municipality names with a trailing article put in natural order ("Coruña, A" becomes "A Coruña"); community codes given as ISO 3166-2:ES; locality names from GeoNames added as alternative city names; coordinates rounded to 5 decimal places; PO-box and large-customer codes added from a committed reference table, with the municipality's median coordinate.
Not endorsed by, or affiliated with, the Instituto Geográfico Nacional, CNIG, the INE or GeoNames.
All sources are CC BY 4.0 and this dataset is distributed under the same licence. No share-alike source (OpenStreetMap, Wikipedia) was used, so nothing here is encumbered by ODbL or CC BY-SA.
Known limitations
- A postal code is not one-to-one with a municipality. Some codes span more than one municipality, while a large city holds
many codes. The primary key is (
postal_code,admin_code3), neverpostal_codealone; joining on the code by itself will fan out. - A code's first two digits identify the serving post office, not the municipality's province, so a few rows
legitimately differ: Condado de Treviño is a Burgos enclave entirely surrounded by Álava and carries
01118; Petilla de Aragón is a Navarrese exclave inside Zaragoza and carries50686; Tresviso is in Cantabria but its only road reaches the network through Asturias, so it carries33554.admin_name2/admin_code2always give the municipality's real province. For the routing province, take the code's first two digits. accuracyhas two tiers.POSTAL_CODEis a point resolved for that individual five-digit code.MUNICIPALITYmarks PO-box and large-customer ranges (XX070,XX071,XX080, plus installation codes such as a nuclear plant and an airport); these have no street geography, so the point is the median of the per-code points resolved inside their municipality. Coordinates are WGS84 / EPSG:4326, decimal degrees, 5 decimal places. No coordinate is interpolated or invented; where the geocoder has no point the cell is empty.- Some postal codes assigned to individual hamlets and installations are not included
(
03459,10150,15591,19131,28851,34260,37467,37608,43518,43729,45489,50176). No open source states which municipality they belong to, and two carry a postal prefix from a different province than their name suggests, so assigning one would be a guess. - PO-box and large-customer codes come from a frozen reference table, so a code added later by the postal operator does not appear until that table is updated.
Municipality names
Names are given in natural reading order. The Spanish statistical register writes
Coruña, A and Madrid, Comunidad de; this dataset ships A Coruña and
Comunidad de Madrid, keeping the register form in alternative_city_name. Bilingual
official names are preserved in full (Alacant/Alicante, Araba/Álava).
Administrative codes
admin_code1 is the ISO 3166-2:ES autonomous-community code with the ES- prefix stripped
(AN, CT, MD…). admin_code2 is the INE two-digit province code. admin_code3 is the
INE five-digit municipality code (CPRO+CMUN), the standard join key for Spanish
statistical, cadastral and electoral data. All three are strings with significant leading
zeros: read them with dtype=str or through the Data Package schema, or 04013 will
silently become 4013.
Usage
The dataset files are available in CSV format and can be accessed and downloaded using
the links provided in datapackage.yaml. Read postal_code as text, never as a number:
Spanish codes can start with zero (01118).
For other inquiries, contact datahub@datopian.com