Free Tool · Pure JavaScript Math

Distance Calculator

This free distance calculator answers how far is it from one place to another. Type two cities, addresses, or GPS coordinates in any common format and get the distance between them in kilometers, miles, nautical miles, and meters, with the initial and final bearing, the midpoint, and the route on a map. Calculated on the WGS 84 ellipsoid, the same Earth model GPS uses, entirely in your browser: no API call, no signup.

It is also a miles calculator and a GPS coordinate distance calculator, and further down the page you will find the distance formula with a small distance formula calculator for math homework.

Calculate distance

London, UK · 51.507351, -0.127758

Paris, France · 48.856614, 2.352222

343.916
Kilometers
213.700
Miles
185.700
Nautical miles
343,916.4
Meters
Initial bearing (at A)
148.05° (SSE)
Final bearing (arriving at B)
149.95° (SSE)
Midpoint
50.188748, 1.146554
Sphere (haversine) for comparison
343.550 km (−0.367 km)

This is the straight-line (“as the crow flies”) distance. For the distance by road, use driving directions. Distance and bearings are calculated on the WGS 84 ellipsoid (Vincenty’s formulae).

What this calculator does

The tool above takes two points and returns the shortest distance between them over Earth’s surface, the kind of distance an airline quotes when it tells you the flight is 5,000 km, not the longer driving distance that follows roads. It calculates on the WGS 84 ellipsoid using Vincenty’s formulae, published in 1975 and widely used in survey and mapping software, and shows:

  • the distance in kilometers, statute miles, nautical miles, and meters
  • the initial bearing leaving A and the final bearing arriving at B
  • the midpoint of the route
  • the spherical haversine distance for comparison, and the difference
  • the great-circle route on a map

Need the coordinates first? The My Location tool gives you yours in two seconds. To see the same point in every format, use the Coordinates Converter. To pick two points visually instead of typing them, drop pins on the interactive map and read off the coordinates.

How far is it? Distance between two places or addresses

You do not need coordinates. To find the distance from one place to another, or the distance between two places, type a city, town, street address or landmark into each box, such as Chicago and Denver, and press Enter or Calculate. The tool finds each place on OpenStreetMap, shows the name it found under the box, and gives the distance in kilometers and miles. For the distance between two addresses, type each full street address with its city.

  • Add the state or country when a name is shared by several places: Perth, Australia or Perth, Scotland; Portland, Oregon or Portland, Maine.
  • A city is measured from its center, as the map service defines it. For an exact spot, type the full address or paste its coordinates.
  • The result is the straight-line distance, sometimes called “as the crow flies”. A trip by road is longer, often much longer; for the road distance and time, use driving directions.

Distance between two points on a map

Every result is drawn on a map: point A, point B, the line between them and the halfway point, so the tool works as a distance between two points map: you see the distance as well as read it. Points can be anything the boxes accept: a city, a street address, a landmark, GPS coordinates, or your own position with Use my location.

  • Address to address: as a distance calculator address to address, type a full street address with its town in each box.
  • Any two locations: to find the distance between 2 locations you only know by name, type the names; the tool shows which place it found under each box so you can check it.
  • Coordinates: as a GPS distance calculator, paste two latitude/longitude pairs in any format.
  • Travel distance: as a travel distance calculator it gives the straight-line distance, which is what flight distances are based on. For the distance by road and the driving time, use driving directions.

Distance between cities in miles

Type two city names to get the distance between cities in miles and kilometers at once. London to Paris is 214 miles (344 km) in a straight line, and San Francisco to Los Angeles is 347 miles (559 km). The same works for the miles between two locations of any kind: towns, airports, landmarks or full street addresses.

How far is it from one country to another?

A country covers a large area, so the Iran to Israel distance, the Iran to America distance or the Iran to India distance has no single answer. The usual answer is the distance between major cities. These are calculated with the tool’s own code; type any two cities into the calculator to measure others.

CountriesFromTokmmiles
Iran to IsraelTehranJerusalem1,559969
Iran to IsraelTehranTel Aviv1,585985
Iran to AmericaTehranWashington, D.C.10,1986,337
Iran to AmericaTehranNew York9,8776,138
Iran to AmericaTehranLos Angeles12,2097,586
Pakistan to IndiaIslamabadNew Delhi688427
Iran to IndiaTehranNew Delhi2,5501,585
Iran to IndiaTehranMumbai2,8001,740

These are straight-line distances. A flight is usually longer, because aircraft follow air routes and avoid closed airspace, and a road trip longer still.

Kitni dur hai? Distance in any language

Searching “Lahore se Karachi kitni dur hai” or “Delhi se Mumbai kitni dur hai”? Type the two city names into the boxes above, in English or in the local spelling, and press Calculate. Lahore to Karachi is 1,032 km (641 miles) in a straight line, and Delhi to Mumbai 1,145 km (711 miles); by road both are longer.

The same works as a Distanzrechner (Entfernung berechnen): Berlin to Munich is 505 km in a straight line. Place names are looked up on OpenStreetMap, which knows most places in their local language as well as in English.

Distance formula: how to find the distance between two points

For two points on a flat grid, such as a graph in a math class or a floor plan, the distance formula is:

d = √((x₂ − x₁)² + (y₂ − y₁)²)

This is how to find the distance between two points: subtract the x values, subtract the y values, square both differences, add them, and take the square root. It is Pythagoras’ theorem, with the two differences as the short sides of a right triangle and the distance between two points as the long side.

Worked example: from (1, 2) to (4, 6), the differences are 4 − 1 = 3 and 6 − 2 = 4, so d = √(3² + 4²) = √(9 + 16) = √25 = 5. In three dimensions, add (z₂ − z₁)² under the square root. Try your own numbers in the distance formula calculator:

Distance formula calculator

d = √((4 − 1)² + (6 − 2)²)

d = √(3² + 4²) = √25

d = 5

The distance formula for latitude and longitude

The flat formula breaks down for places on Earth, because a degree of longitude shrinks from about 111 km at the equator to zero at the poles. Calculating distance between GPS coordinates needs a formula for a sphere or an ellipsoid. The common one is the haversine formula, with latitudes φ and longitudes λ in radians and Earth’s mean radius R = 6,371 km:

a = sin²(Δφ/2) + cos φ₁ · cos φ₂ · sin²(Δλ/2)
d = 2R · atan2(√a, √(1 − a))

The calculator at the top of this page goes one step further and uses Vincenty’s formulae on the WGS 84 ellipsoid, the Earth model GPS uses, and shows the haversine answer next to it so you can see the difference.

Miles calculator: kilometers to miles

Every result is shown in miles and kilometers at once, so the tool doubles as a miles calculator. The conversion is exact by definition: 1 mile = 1.609344 km and 1 km = 0.621371 miles. A nautical mile, used at sea and in the air, is exactly 1.852 km.

MilesKilometers
11.609
58.047
1016.1
26.2 (marathon)42.2
5080.5
100160.9
500804.7
10001609.3

Mile tracker: the distance you actually travel

This calculator measures between two fixed points. To log the distance you walk, run or drive as you go, like a mile tracker, open Live Location, which adds up the distance travelled from your phone’s GPS and can save the route as a GPX file.

GPS distance calculator in meters

For short distances, such as across a field, along a street or between two survey marks, read the Meters box, which shows the GPS distance to a tenth of a meter. Paste the two GPS coordinates with at least five decimal places: five decimals pin a point to about 1.1 m, six to about 11 cm.

The calculation is exact; the coordinates usually are not. A smartphone’s GPS is typically accurate to within about 4.9 m (16 ft) under open sky, according to GPS.gov, and worse near buildings or trees. Two readings taken standing still can be several meters apart, so for a distance of a few meters, take each reading more than once.

Enter latitude and longitude in any format

Each point box reads the same formats as our coordinate converter, and shows underneath how it understood your input:

  • Decimal degrees: 51.5074, -0.1278 or 51.5074° N, 0.1278° W
  • DMS: 51°30'26.6"N 0°07'40.1"W
  • DDM: 51°30.444'N 0°07.668'W
  • UTM: 30U 699316 5710164
  • A Google Maps link containing @lat,lon

You can mix formats: a DMS point A and a UTM point B work fine. Out-of-range values are flagged instead of producing a wrong distance.

Sanity-check the math against known distances

The first time you use any GPS coordinate distance calculator, it pays to verify it against pairs you already know. These six city pairs are calculated with the calculator’s own code when the page is built, so pasting any pair into the tool gives exactly these numbers. The last two columns show what a spherical haversine calculator would say instead, and how far off that is.

FromTokmmiNMSphere kmSphere error
London (51.5074, -0.1278)Paris (48.8566, 2.3522)344214186344−0.4 km
New York JFK (40.6413, -73.7781)London LHR (51.47, -0.4543)5,5553,4522,9995,540−14.9 km
Karachi (24.8607, 67.0011)Dubai (25.2048, 55.2708)1,1847366391,182−2.0 km
Sydney (-33.8688, 151.2093)Tokyo (35.6762, 139.6503)7,7924,8424,2077,826+33.7 km
San Francisco (37.7749, -122.4194)Los Angeles (34.0522, -118.2437)559347302559+0.1 km
Cape Town (-33.9249, 18.4241)Cairo (30.0444, 31.2357)7,2074,4793,8927,239+31.8 km

Distances are rounded to the nearest whole unit. Checked against the GeographicLib reference library in October 2026. How the two methods differ by direction and latitude, and where Vincenty fails, is measured in haversine vs Vincenty.

How accurate is great-circle distance, really?

Earth is not a perfect sphere. Its spin makes it bulge at the equator: the equatorial radius is about 21 km larger than the polar radius. The haversine formula, which most online distance calculators use, ignores that and treats Earth as a ball with a 6,371 km radius. This calculator instead uses the WGS 84 ellipsoid, the model GPS itself uses, so the bulge is accounted for.

We tested the calculator against GeographicLib, the reference library used in GIS software, on 20,000 random pairs of points around the world. The largest difference was under 0.1 mm. In practice your input is the limit: six decimal places pin each point to about 11 cm.

Haversine vs ellipsoid: when the difference matters

The spherical haversine shortcut is wrong by up to about 0.56%, and the error depends on direction and latitude. It is worst for short north–south trips near the equator, where it overstates distance by up to about 0.56%, and for short trips near the poles, where it understates by up to about 0.44%. Over very long routes the errors partly cancel; from the equator to the North Pole it is only about 0.06% off.

In kilometers, the table above shows it plainly: haversine is about 15 km short on New York to London and about 32 km long on Cape Town to Cairo. That is irrelevant for estimating a flight time and very relevant for fuel planning, surveying, or checking a developer’s own distance code. The “sphere” line in the tool shows the gap for whatever two points you enter.

Why driving distance is always longer

People sometimes punch in two coordinates expecting the driving distance and are surprised when the result is much smaller. Driving distance has to follow roads, go around lakes and mountains, respect one-way streets, and divert through interchanges. A drive from London to Paris is about 460 km along roads, but only about 344 km in a straight line over the English Channel. The straight-line version is the one this page calculates.

If what you actually want is the road distance, use the Driving Directions tool instead. It calls the routing engine that does know about roads. Across the US, roads average about 1.4 times the straight-line distance.

What the bearing field tells you

The calculator returns two bearings. The initial bearing is the compass direction you set off in from point A; the final bearing is the direction you are travelling when you arrive at point B. On the shortest route the two are usually different, because a great circle crosses each meridian at a different angle. London to Tokyo leaves London heading about 32° (north-northeast) and arrives in Tokyo heading about 156° (south-southeast), even though Tokyo is south of London on the map.

The midpoint between two coordinates

The midpoint is the place exactly halfway along the shortest route, and it is shown as an orange dot on the map. It is not the average of the two latitudes and longitudes: averaging New York and Sydney gives 3.4°N, 38.6°E, in East Africa near the Ethiopia–Kenya border, while the real halfway point is in the central Pacific, near 8.9°N, 147.7°W. The tool walks half the route’s length along the ellipsoid from point A to find it.

Reading the great-circle line on the map

The blue line is the actual shortest route. On a flat web map it usually looks curved, bowing toward the nearer pole, because the map stretches the globe sideways. That curve is the straight line on the real planet. Routes that cross the 180° meridian, such as Tokyo to Los Angeles, are drawn across the Pacific rather than the long way round the map.

Frequently asked questions

How far is Iran from India?

Tehran to New Delhi is about 2,550 km (1,585 miles) in a straight line, and Tehran to Mumbai about 2,800 km (1,740 miles). Pakistan lies between the two countries, so their nearest border points are closer than their capitals. Type any two cities into the calculator for others.

What is the distance formula?

The distance between two points (x₁, y₁) and (x₂, y₂) on a flat grid is d = √((x₂ − x₁)² + (y₂ − y₁)²). It is Pythagoras' theorem: the horizontal and vertical differences are the two short sides of a right triangle, and the distance is the long side. In 3D, add (z₂ − z₁)² under the square root. For latitude and longitude it does not work, because Earth is round; use the haversine formula or this page's calculator instead.

How far is Iran from Israel?

Tehran to Jerusalem is about 1,559 km (969 miles) in a straight line, and Tehran to Tel Aviv about 1,585 km (985 miles). The two countries do not share a border: Iraq and Jordan or Syria lie between them, so the closest points of the two countries are much nearer than their big cities. For any other pair of cities, type both names into the calculator above.

How far is Iran from America?

Tehran to Washington, D.C. is about 10,198 km (6,337 miles) along the shortest route over Earth's surface, Tehran to New York about 9,877 km (6,138 miles), and Tehran to Los Angeles about 12,209 km (7,586 miles). The shortest route from Tehran to the US East Coast heads northwest over Europe and the North Atlantic, which is why it looks curved on a flat map.

How do I calculate the distance between two GPS coordinates?

Paste each point into the tool above, latitude first, in any common format: decimal degrees, DMS, DDM, or UTM. The page returns the distance in kilometers, miles, nautical miles, and meters, the initial and final bearing, the midpoint, and a map of the route. The math runs entirely in your browser; no signup, no API call. For an outdoor measurement against a known landmark, six decimals of input precision is more than enough.

Does this calculator use the haversine formula or Vincenty?

Both. The main result uses Vincenty's formulae on the WGS 84 ellipsoid, the shape GPS uses, which agrees with the GeographicLib reference library to well under a millimeter. The haversine result, which treats Earth as a sphere with a 6,371 km radius, is shown underneath for comparison, with the difference. For two points almost exactly opposite each other on the globe, where Vincenty's method does not converge, the tool falls back to haversine and says so.

How is great-circle distance different from driving distance?

Great-circle distance is the straight line over Earth's surface. Driving distance follows roads — going around lakes, respecting one-way streets, diverting through interchanges. London to Paris is about 460 km by road but only about 344 km in a straight line over the English Channel. If you need the road distance, use a routing tool like Google Maps or Apple Maps; this calculator only computes the geodesic line.

How accurate is this calculator?

The main result is calculated on the WGS 84 ellipsoid and, in our tests on 20,000 random point pairs, matched the GeographicLib reference library to within 0.1 mm. The real limit is your input: six decimal places of latitude and longitude pin each point to about 11 cm. The spherical haversine figure shown for comparison can be off by up to about 0.56%, which is 5.6 km on a 1,000 km trip.

How do I find the GPS coordinates of two points?

For your current location, tap Use my location under point A, or open the My Location tool and tap Find my location. For other places, search a landmark in Google Maps, long-press (or right-click) the spot, and the coordinates appear at the top of the panel. Paste them straight into this calculator; DMS and UTM work too.

What units does the distance calculator support?

Kilometers (km), statute miles (mi), nautical miles (NM), and meters (m). All four are computed from the same ellipsoidal result, so they are exactly consistent — no rounding mismatches between the displayed values. Nautical miles are useful for marine and aviation; meters are useful for short distances (under a kilometer) where the other units lose precision in the trailing digits.

What is the midpoint between two coordinates?

The midpoint is the point exactly halfway along the shortest route between them, not the average of the two latitudes and longitudes. Averaging works for nearby points but goes badly wrong over long distances and across the 180th meridian. The tool computes the true halfway point on the ellipsoid and marks it on the map in orange.

Useful companion tools