Distance between cities in Spain
Pick two cities or towns in Spain to see how many kilometers (or miles) separate them in a straight line and by road, and how long the drive takes.
Example From Madrid to Valencia. Change the points to measure your own.
Loading the map…
Result
In a straight line
302kmMadrid → Valencia
- Initial bearing
- 109° (E)
- In the other unit
- 188 mi
- Madrid
- Population 3,506,730 (municipal register, 2025)
- Valencia
- Population 840,792 (municipal register, 2025)
By road
Tap a way to travel to see the distance and time along the route.
To give you an idea
60% of Madrid – Barcelona
What next?
Take these two cities to another tool, without searching again.
Save or share this trip
How to use it
-
Type the first town
Start typing and pick from the list: it has the 3,152 Spanish municipalities with 1,000 residents or more, plus every provincial capital. Spanish and regional names both work (Alicante or Alacant, San Sebastián or Donostia), accents are optional, and so are a few English ones like Seville.
-
Type the second one
As soon as both are set, the map draws the straight line and the driving route. Use Swap to flip the trip around.
-
Compare and share
Read the straight-line and driving distance, the drive time and the bearing. Distances start in kilometers, the unit on every Spanish road sign; tap “mi” for miles and the tool remembers it.
What it’s for
-
Planning a trip around Spain
See how far Seville is from Granada or Madrid from Toledo before choosing between a rental car, a coach or one of Spain’s high-speed trains.
-
Moving or studying
Check how far the city you might move to, or your exchange university, is from the airport or from family in another region.
-
Work and quotes
Work out the kilometers between clients, branches or warehouses for quotes, expense claims or a sales route.
-
Spanish class
Use real distances between capitals to practice numbers and geography, and see why the road is always longer than the straight line.
How it’s calculated
Spain is divided into more than 8,100 municipalities (municipios), the local councils that run each town and its surrounding land. One municipality can include several villages, so the tool places each one at its main settlement: the point the Nomenclátor Geográfico of Spain’s National Geographic Institute (IGN) gives for the town center, usually near the town hall or the main church. Between the two points, Mapsfera measures the shortest line on the WGS84 ellipsoid with GeographicLib.
The driving distance comes live from the FOSSGIS OSRM routing service, using OpenStreetMap data: it’s the length of the fastest route by car (or bike, or on foot), which in Spain usually means the autovías, the free four-lane highways that fan out from Madrid.
As the crow flies
d = length of the geodesic between the two points (WGS84)
The straight-line distance: what a plane flying the shortest path would cover.
By road
d = sum of the legs of the fastest route
Worked out by OSRM on OpenStreetMap roads, using their speed limits (up to 120 km/h on Spanish highways).
| Madrid | 40.41903° N, 3.69198° W |
|---|---|
| Barcelona | 41.38229° N, 2.17744° E |
| As the crow flies | 506 km (314 mi) |
| By road | Tap it in the tool: it’s calculated live |
Population comes from the padrón, Spain’s official register of residents that every town council keeps: the figures are those of January 1, 2025, published by the National Statistics Institute (INE).
Distances between major Spanish cities
As the crow flies, between the town-center points of each city. Tap “See on the map” to open the pair in the tool and get the driving distance too.
| Cities | Kilometers | Miles | Bearing | See on the map |
|---|---|---|---|---|
| Madrid – Barcelona | 506 km | 314 mi | 76° E | See on the map |
| Madrid – Valencia | 302 km | 188 mi | 109° E | See on the map |
| Madrid – Sevilla | 391 km | 243 mi | 211° SW | See on the map |
| Madrid – Zaragoza | 274 km | 170 mi | 59° NE | See on the map |
| Madrid – Málaga | 415 km | 258 mi | 189° S | See on the map |
| Madrid – Bilbao | 322 km | 200 mi | 11° N | See on the map |
| Madrid – Alicante | 360 km | 224 mi | 129° SE | See on the map |
| Madrid – A Coruña | 510 km | 317 mi | 312° NW | See on the map |
| Madrid – Granada | 360 km | 224 mi | 179° S | See on the map |
| Madrid – Salamanca | 177 km | 110 mi | 291° W | See on the map |
| Madrid – Toledo | 68.6 km | 42.6 mi | 205° SW | See on the map |
| Barcelona – Valencia | 303 km | 189 mi | 226° SW | See on the map |
| Barcelona – Zaragoza | 257 km | 160 mi | 278° W | See on the map |
| Barcelona – Bilbao | 469 km | 292 mi | 298° NW | See on the map |
| Sevilla – Málaga | 159 km | 98.7 mi | 117° SE | See on the map |
| Sevilla – Granada | 214 km | 133 mi | 96° E | See on the map |
| Valencia – Alicante | 125 km | 77.8 mi | 184° S | See on the map |
| Bilbao – San Sebastián | 76.4 km | 47.5 mi | 85° E | See on the map |
| Oviedo – Gijón | 25.3 km | 15.7 mi | 36° NE | See on the map |
| Vigo – Santiago de Compostela | 73.1 km | 45.4 mi | 12° N | See on the map |
Calculated on the WGS84 ellipsoid from IGN Nomenclátor points. Driving distances aren’t in the table because they change with roadwork and new highways: the tool calculates them on the spot.
Provinces, regions and city names
Under each town the list shows its province. Spain has 50 provinces, grouped into 17 autonomous communities (regions such as Andalusia or Catalonia), plus the autonomous cities of Ceuta and Melilla in North Africa. Several towns share a name, like the many Villanuevas, and the province is how you tell them apart.
In regions with a second official language, the official name may be bilingual or only in that language: València, A Coruña, Girona, Donostia/San Sebastián. The search accepts the Spanish form, the regional one and both together.
The Balearic and Canary Islands
Islands are measured the same way in a straight line: Barcelona – Palma: 205 km (128 mi), Valencia – Palma: 261 km (162 mi), Madrid – Las Palmas de Gran Canaria: 1,737 km (1,079 mi) and Las Palmas de Gran Canaria – Santa Cruz de Tenerife: 89.6 km (55.7 mi).
By road, the driving route uses the car ferries mapped in OpenStreetMap, such as those from Barcelona, Valencia or Dénia to the Balearic Islands, and adds the crossing to the distance. If no car ferry links the two places, the tool says there’s no road route and keeps the straight-line figure. Ferry times are rough: check the shipping line’s timetable.
Frequently asked questions
How many kilometers is it from Madrid to Barcelona?
506 km (314 mi) as the crow flies, between the center of Madrid and that of Barcelona. By road it’s farther: pick both cities above and the tool gives you the distance and the drive time.
Which towns are included?
The 3,152 municipalities with 1,000 or more registered residents in 2025, plus all provincial capitals and Ceuta and Melilla. For smaller villages, use the distance between two municipalities or the distance calculator.
What is a municipality in Spain?
The basic unit of local government, with its own town council (ayuntamiento). Its land, the término municipal, can hold a main town plus hamlets and housing estates. Each municipality has a five-digit INE code; the first two digits are its province.
Where in each town is the distance measured from?
From the IGN point for the municipality’s main town, usually in the old center. It isn’t the geographic middle of the municipality, which in large rural ones can be miles away from the town itself.
Can I see the distance in miles?
Yes. Spanish tools start in kilometers, as on road signs in Spain, but the km and mi buttons switch every figure, and your choice is kept for the other distance tools.
Is the driving route the shortest one?
It’s the fastest one according to OpenStreetMap speed limits, which usually means the autovía even if it adds a few kilometers. That’s why it may not match other navigation apps exactly.
Does it work offline?
The town search does: the list comes with the page and doesn’t ask any server. The map and the driving distance need a connection.
Related tools
All toolsSources
- Population of each municipality (padrón municipal) · INE, official figures as of January 1, 2025. Mapsfera with data from the INE website
- Town-center point of each municipality · IGN, Nomenclátor Geográfico de Municipios y Entidades de Población (CC BY 4.0)
- GeographicLib (distances, bearings and midpoints on the WGS84 ellipsoid) · Charles F. F. Karney (MIT license)
- Driving, cycling and walking routes (OSRM) · FOSSGIS e. V., with OpenStreetMap data
- Base map · OpenFreeMap, with data © OpenStreetMap contributors