Distance Matrix Calculator
Pairwise great-circle distances between many places — table and CSV export.
By Aryan Khan, Founder & Editor · Updated October 21, 2026
In plain terms, with the built-in US cities sample loaded: the closest pair is New York ↔ Chicago at approx. 711 miles (1,144 km), and the farthest pair is New York ↔ Los Angeles at approx. 2,446 miles (3,936 km) — every other pair falls between those two.
How to use the distance matrix calculator
A matrix answers a different question from a single distance: not “how far is A from B?” but “how far is everything from everything else?”. Build it once, and the comparisons you actually need — closest, farthest, most central — are already on the page.
A distance matrix compares every pair in a list of places. Use straight-line mode for geographic separation or a routing mode for network distance. Read both directions when routes are directional, and keep the selected units with any exported table.
- 1Add your places: search by name, click the map, load a sample, or paste a list of coordinates — up to 50 in straight-line mode.
- 2Choose a mode — straight line, drive, walk or cycle — and, for the network modes, press the calculate button.
- 3Read the matrix or the pair list in miles or kilometres, check the nearest and farthest pairs, then download Wide or Long CSV.
What people use a distance matrix for
A distance matrix compares every origin with every destination so you can see relative separation at a glance instead of running dozens of individual calculations. It is the right instrument when a single distance is not the question — comparing candidate warehouse sites against several markets, clustering field samples, checking which branches are closest to which customers, or building an origin–destination table for a class exercise.
Logistics and delivery planning
Sketch which depots can serve which cities before committing to routed schedules. The straight-line matrix is the fast first pass; run the critical pairs in drive mode, or through the Driving Distance Calculator, before promising delivery windows.
Choosing a warehouse or store location
Put each candidate site in the matrix alongside your markets and read down its column: the candidate with the lowest total and worst-case distances is usually the one worth a site visit. A matrix makes that comparison visible instead of anecdotal.
Franchise and territory planning
Check how far apart existing and proposed territories sit, spot two outlets quietly competing for the same town, and keep new locations a defensible distance from established ones — in the US Midwest or across European regions alike.
Multi-city trips, teaching and research
Plan the shape of a multi-city business trip or road trip before sequencing it, or use the matrix as clean origin–destination data in a geography lesson or study. Export the CSV and the same numbers drop straight into a spreadsheet or notebook.
Worked examples
Load the tool's built-in US cities sample (New York, Chicago, Los Angeles, Houston) and the six unique pairs read: New York ↔ Chicago 711.0 miles (1,144.3 km), Chicago ↔ Houston 941.9 miles (1,515.8 km), New York ↔ Houston 1,417.6 miles (2,281.3 km), Los Angeles ↔ Houston 1,370.9 miles (2,206.3 km), Chicago ↔ Los Angeles 1,742.3 miles (2,804.0 km) and New York ↔ Los Angeles 2,445.6 miles (3,935.8 km). Closest pair: New York ↔ Chicago. Farthest pair: New York ↔ Los Angeles. Every figure is reproducible in the tool itself — press “Sample: US cities” and compare.
The built-in Europe sample (London, Paris, Berlin, Rome) gives: London ↔ Paris 343.5 km (213.5 miles), Paris ↔ Berlin 877.5 km (545.2 miles), London ↔ Berlin 931.6 km (578.8 miles), Paris ↔ Rome 1,105.3 km (686.8 miles), Berlin ↔ Rome 1,182.5 km (734.8 miles) and London ↔ Rome 1,433.8 km (890.9 miles). Closest pair: London ↔ Paris. Farthest pair: London ↔ Rome. Distances are straight-line; the driven routes are longer, because European road networks, like US interstates, cannot follow the geometric minimum.
Popular city pairs
Straight-line distances between city centres, computed with this tool's own formula (haversine, mean Earth radius 6,371.0088 km) and rounded to the nearest mile and kilometre — approx. values for planning and comparison, not road mileage. Type any pair into the calculator above to reproduce it.
| From | To | Miles | Kilometres |
|---|---|---|---|
| New York | Chicago | 711 | 1,144 |
| New York | Los Angeles | 2,446 | 3,936 |
| Chicago | Los Angeles | 1,742 | 2,804 |
| Dallas | Houston | 225 | 362 |
| New York | Miami | 1,092 | 1,758 |
| London | Paris | 213 | 344 |
| Paris | Berlin | 545 | 878 |
| London | Berlin | 579 | 932 |
| Madrid | Barcelona | 314 | 505 |
| Rome | Vienna | 475 | 764 |
How the distances are calculated
For every pair of places, the straight-line mode converts both coordinates to radians and applies the haversine formula on a sphere with a mean Earth radius of R = 6,371.0088 km:
a = sin²(Δφ/2) + cos φ₁ · cos φ₂ · sin²(Δλ/2)
c = 2 · atan2(√a, √(1 − a))
d = R · c
Here φ is latitude, λ is longitude and Δ is the difference between the two points. Haversine stays numerically stable for very small distances, where the simpler spherical law of cosines loses precision. Because the Earth is an oblate ellipsoid rather than a perfect sphere, a haversine result differs from a full ellipsoidal geodesic by about 0.3% at most for typical pairs — immaterial for planning, comparison and teaching, and the reason the matrix can be computed instantly for up to 50 places. Interpret the matrix according to the metric being used: a straight-line matrix is excellent for geographic structure, but it should not be substituted for road travel time when routing matters. Also watch for duplicate or ambiguously geocoded place names; one bad location creates an entire misleading row and column.
The drive, walk and cycle modes are different by design: coordinates are sent to the Valhalla routing engine running on OpenStreetMap data, which assembles each cell from real road segments and returns both distance and duration.
When to use something else: for an exact road itinerary with turn-by-turn legs, use the Driving Distance Calculator or the routing mode here; for surveying, engineering or legal work, use dedicated ellipsoidal geodesic software and authoritative coordinates; and for airline mileage, remember that carriers credit their own programme rules rather than any calculator's great-circle figure.
Related tools and resources
When the question narrows to a single pair, the Distance Between Two Places calculator adds the bearing and midpoint that a matrix cell leaves out. The As the Crow Flies Distance tool makes the straight-line idea explicit for one origin and destination, while the Driving Distance Calculator follows the road network when the driven figure is the one that matters. Once a matrix has shown you the shape of a trip, the Multi-Stop Route Planner turns the same places into an ordered route. For the full reasoning behind spherical distance — including where the simpler formulas break — read our guide to how distance calculation works.
Method, assumptions & limits
- This tool’s method
- Haversine great-circle distances on WGS84 for every ordered pair of points.
- Before relying on the answer
- Keep the endpoints and measurement mode fixed when comparing results. A surface separation, a compass bearing and a road distance are different outputs.
- What the result cannot establish
- A rounded coordinate or a city-centre search changes the endpoints. Do not interpret displayed decimal places as survey accuracy.
Coverage: Worldwide. Search, basemap and external data requests may use third-party services; browser-based does not mean every operation is offline. Read the source and licence notes, calculation methodology and privacy policy. If a result looks inconsistent, report a correction with the inputs and mode used.
Frequently asked questions
Clear answers about the calculation, accuracy and appropriate use.
How many places can I add to the matrix?
Up to 50 places in straight-line mode — that is 1,225 unique pairs. The drive, walk and cycle modes are limited to 15 places, because every cell needs its own routed network calculation.
Is this driving distance or straight-line distance?
Both are available. Straight-line (great-circle) distance is the default and is calculated instantly in your browser. Switch to Drive, Walk or Cycle mode and press the calculate button to fill the same matrix with road-network distances and travel times.
How accurate are the straight-line distances?
They use the haversine formula on a sphere with a mean Earth radius of 6,371.0088 km, which agrees with an ellipsoidal geodesic to within about 0.3% for most pairs. The result is also only as accurate as the coordinates of the places you enter.
Can I export the matrix?
Yes. The Wide CSV button downloads the matrix as a grid with place labels across the top and side; the Long CSV button downloads one row per pair, with a minutes column added in the drive, walk and cycle modes. Distances follow the unit (km or mi) you have selected.
Can I use coordinates instead of place names?
Yes. Search for a place, click the map, use your device location where offered, or open “Paste a list of coordinates” and import one place per line in the form: Name, latitude, longitude.
Is the matrix symmetric?
In straight-line mode, yes — the distance from A to B always equals B to A, and the diagonal is empty. In the drive, walk and cycle modes a cell can differ by direction, because one-way streets and turn restrictions make some routes directional.
Does the calculator work out the best order to visit the places?
No. The matrix tells you how far apart every pair is; it does not sequence a trip. For stop ordering, use the Multi-Stop Route Planner — a matrix like this one is the input that route-optimization tools reason over.
Should I read the table in miles or kilometres?
Whichever your work uses — the km/mi toggle switches the matrix, the pair list and the CSV export together. On this page, US examples are written miles first and European examples kilometres first.
Can I mix US and European cities in one matrix?
Yes, the calculator works worldwide and places from different continents can share one matrix. Straight-line mode handles any combination; the drive, walk and cycle modes need a routable land connection, so a transatlantic pair will honestly report “No route”.
Why is the road distance longer than the straight-line distance?
Roads follow the available network — terrain, rivers, bridges and restrictions — while the straight line is the geometric minimum between two points. European road networks and US interstates both make the driven distance longer than the crow-flies figure; the gap is information, not an error.
Is anything I enter uploaded or stored?
Straight-line distances are calculated locally in your browser and nothing is stored. The drive, walk and cycle modes send the coordinates to the public Valhalla routing service (built on OpenStreetMap data) to compute the network matrix.
Sources, methodology & editorial trust
- ✓ Browser-first processing where supported
- ✓ External sources are documented
- ✓ No account required for public tools
- ✓ Review data sources
Calculations are documented with their assumptions, limitations and source context rather than presented as unexplained answers.
Reviewed and maintained by Aryan Khan, Founder & Editor of MapBench.