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
Postal Code
place_name
string
Municipality name in natural reading order
required
Place Name
admin_name1
string
Autonomous community (comunidad autónoma)
required
Administrative Name 1
admin_code1
string
ISO 3166-2:ES autonomous-community code, ES- prefix stripped
pattern ^[A-Z]{2}$ · required
Administrative Code 1
admin_name2
string
Province (provincia)
required
Administrative Name 2
admin_code2
string
INE province code (CPRO), 01-52
pattern ^\d{2}$ · required
Administrative Code 2
admin_name3
string
Municipality (municipio)
required
Administrative Name 3
admin_code3
string
INE municipality code (CPRO+CMUN), five digits
pattern ^\d{5}$ · required
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
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.
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), never postal_code alone; 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 carries 50686; Tresviso is in Cantabria but its only road reaches the
network through Asturias, so it carries 33554. admin_name2 / admin_code2 always give the municipality's real
province. For the routing province, take the code's first two digits.
accuracy has two tiers. POSTAL_CODE is a point resolved for that individual five-digit code. MUNICIPALITY marks
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).