The Haversine Distance Calculator finds the great-circle distance — the shortest path across the surface of the Earth — between any two geographic coordinates. Enter two pairs of decimal-degree latitude/longitude values and the tool returns the distance in kilometres, miles, nautical miles, and metres, plus the initial compass bearing in both directions. Everything runs inside your browser; no data is uploaded anywhere.
How it works
The Earth is treated as a sphere with the IUGG mean radius R = 6 371.009 km. The great-circle distance between two points (lat1, lon1) and (lat2, lon2) — all in radians — is found with the Haversine formula:
a = sin²(dLat/2) + cos(lat1) · cos(lat2) · sin²(dLon/2)
c = 2 · asin(sqrt(a))
d = R · c
where dLat = lat2 − lat1 and dLon = lon2 − lon1.
The intermediate value a is the square of half the chord length between the two
points; it is always in [0, 1], which prevents asin from returning NaN due to
floating-point rounding. The central angle c (in radians) is then multiplied by
the Earth radius to get the arc length.
Initial bearing from A to B uses the four-quadrant arctangent of the cross-track components:
y = sin(dLon) · cos(lat2)
x = cos(lat1)·sin(lat2) − sin(lat1)·cos(lat2)·cos(dLon)
bearing = atan2(y, x) (converted to 0–360°)
The reverse bearing (B → A) is calculated identically with the coordinates swapped, not just by adding 180° — because on a curved surface the two headings differ except along meridians and the equator.
Worked example: London to New York
| Property | Value |
|---|---|
| Point A | 51.5074° N, 0.1278° W |
| Point B | 40.7128° N, 74.0060° W |
| dLat | −10.7946° = −0.18840 rad |
| dLon | −73.8782° = −1.28942 rad |
| a | 0.17924 |
| c | 0.87431 rad |
| Distance | 5 570.2 km (3 461.2 mi, 3 007.7 NM) |
| Forward bearing | 288.3° (WNW) |
| Reverse bearing | 51.2° (NE) |
The Haversine result agrees with published great-circle distances for this route to within 1 km. The asymmetry of the bearings (283° outbound vs 51° return) illustrates how initial headings diverge on a sphere.
Coordinate entry tips
- Decimal degrees are the simplest format:
51.5074for 51° 30’ 26” N. - West longitudes and south latitudes are negative:
-74.006for 74° W. - Most smartphone GPS apps and Google Maps display decimal degrees in the “What’s here?” popup — tap the coordinates to copy them.
- The tool includes four quick-preset routes (London → New York, Sydney → Tokyo, Paris → Dubai, Yerevan → Tbilisi) to demonstrate typical results at a glance.
Limitations and alternatives
The Haversine formula assumes a spherical Earth. The real Earth is an oblate spheroid, so the maximum error is about 0.5% for antipodal points. For most navigation, mapping, and logistics use-cases this is negligible. If you need sub-metre geodetic precision — such as survey-grade GPS processing — use Vincenty’s inverse formula or the Karney (2013) geodesic method, which model the WGS-84 ellipsoid.
Unit conversions used: 1 km = 0.621 371 mi (exactly); 1 nautical mile = 1.852 km (exactly, since 1954); 1 km = 1 000 m.