Haversine Distance Calculator
Enter two pairs of latitude/longitude coordinates to instantly compute the straight-line great-circle distance using the Haversine formula — the standard method used in navigation, mapping APIs, and geospatial development.
Great-circle distance
Kilometers
5,570.22
Miles
3,461.17
Nautical miles
3,007.68
Formula used
a = sin²(Δlat/2) + cos(lat₁)·cos(lat₂)·sin²(Δlon/2)
c = 2·atan2(√a, √(1−a))
d = R·c, where R = 6,371 km (mean Earth radius)
Quick answer
The Haversine formula calculates the shortest distance between two points on a sphere using their latitude and longitude coordinates. It accounts for the Earth's curvature and returns the great-circle distance — the shortest path along the surface. For most navigation and geospatial tasks, Haversine gives accuracy within 0.3% because the Earth is nearly spherical. The result is typically expressed in kilometers or miles.
Formula & method
a = sin²(Δlat/2) + cos(lat₁)·cos(lat₂)·sin²(Δlon/2)
- Δlat — Difference in latitudes in radians (lat₂ − lat₁)
- Δlon — Difference in longitudes in radians (lon₂ − lon₁)
- lat₁, lat₂ — Latitudes of point 1 and point 2 in radians
Intermediate value 'a' — the square of half the chord length between two points
c = 2 · atan2(√a, √(1−a))
- a — Intermediate value from the first formula
- atan2 — Two-argument arctangent function
Angular distance in radians between the two points
d = R · c
- d — Great-circle distance between the two points
- R — Earth's mean radius ≈ 6,371 km (3,958.8 miles)
- c — Angular distance in radians from the second formula
Great-circle distance, where R is Earth's mean radius (6,371 km)
Examples
- Input
- Point A: 40.7128° N, 74.0060° W | Point B: 51.5074° N, 0.1278° W
- Result
- 5,570.22 km / 3,461.17 mi
- Why
- Using the Haversine formula with lat1=40.7128°, lon1=−74.0060°, lat2=51.5074°, lon2=−0.1278°, the angular difference terms give a≈0.2248 and c≈0.8739 radians, yielding d = 6371 × 0.8739 ≈ 5,570 km. This matches typical transatlantic flight distances quoted by airlines.
- Input
- Point A: 48.8566° N, 2.3522° E | Point B: 52.5200° N, 13.4050° E
- Result
- 877.46 km / 545.23 mi
- Why
- With lat1=48.8566°, lon1=2.3522°, lat2=52.5200°, lon2=13.4050°, the formula gives a≈0.009478 and c≈0.13774 radians, so d = 6371 × 0.13774 ≈ 877 km. This closely aligns with the ~879 km figure commonly cited for the Paris–Berlin rail corridor.
- Input
- Point A: 35.6762° N, 139.6503° E | Point B: 33.8688° S, 151.2093° E
- Result
- 7,825.82 km / 4,862.74 mi
- Why
- Tokyo (lat=35.6762°, lon=139.6503°) and Sydney (lat=−33.8688°, lon=151.2093°) span both hemispheres. The Haversine gives a≈0.2997 and c≈1.2284 radians, yielding d = 6371 × 1.2284 ≈ 7,826 km. Direct flights between the two cities typically cover about 7,800–7,830 km.
- Input
- Point A: 34.0522° N, 118.2437° W | Point B: 41.8781° N, 87.6298° W
- Result
- 2,803.97 km / 1,742.31 mi
- Why
- Los Angeles (lat=34.0522°, lon=−118.2437°) to Chicago (lat=41.8781°, lon=−87.6298°) gives a≈0.04816 and c≈0.44024 radians, so d = 6371 × 0.44024 ≈ 2,804 km. Cross-country flights between LAX and ORD typically cover 2,800–2,815 km great-circle distance.
Frequently asked questions
What is the Haversine formula used for?
The Haversine formula calculates the great-circle distance between two points on a sphere given their latitude and longitude. It is widely used in geospatial programming, GPS navigation, mapping APIs (such as Google Maps), aviation route planning, and location-based services to find the shortest over-the-surface distance between two coordinates.
How accurate is the Haversine formula?
The Haversine formula assumes the Earth is a perfect sphere with radius 6,371 km. In reality, the Earth is an oblate spheroid, so Haversine has an error of up to about 0.3% (roughly 17 km for a 5,000 km distance). For most navigation and development purposes this is acceptable. If you need sub-meter accuracy, use the Vincenty formula or an ellipsoidal model.
What is the difference between great-circle distance and straight-line distance?
A straight-line (Euclidean) distance passes through the Earth's interior — useful in 3D space but not for surface travel. Great-circle distance is the shortest path along the Earth's surface between two points, following the arc of a circle whose center is the Earth's center. Haversine computes the great-circle distance, which is the relevant measure for ships, aircraft, and GPS routing.
Can I enter coordinates in degrees, minutes, and seconds (DMS)?
This calculator accepts decimal degrees, which is the standard format for programming and APIs. To convert from DMS (e.g., 40° 42' 46" N) to decimal degrees, use: Decimal = Degrees + (Minutes/60) + (Seconds/3600). So 40° 42' 46" N = 40 + 42/60 + 46/3600 ≈ 40.7128°. Southern latitudes and western longitudes are negative (e.g., 34° S = −34.0).
What Earth radius does this calculator use?
This calculator uses 6,371 km (3,958.8 miles), the International Union of Geodesy and Geophysics (IUGG) mean Earth radius. Some tools use the equatorial radius (6,378 km) or the polar radius (6,357 km). Using the mean radius gives the best average accuracy for distances at all latitudes.
Why do latitude values need to be between −90 and 90?
Latitude measures angular position north or south of the equator. The equator is 0°, the North Pole is +90°, and the South Pole is −90°. Values outside this range do not represent valid points on Earth. Longitude ranges from −180° to +180°, measuring east or west of the Prime Meridian. If you enter coordinates from a GPS or map application, they will already be in the correct range.
Sources & references
- https://www.movable-type.co.uk/scripts/latlong.html
- https://en.wikipedia.org/wiki/Haversine_formula
- https://www.iugg.org/resolutions/iugg_resolutions_1999.pdf
External references open in a new tab. We are independent and not affiliated with these organizations.
- ✓ Free to use
- ✓ No sign-up required
- ✓ Runs entirely in your browser — nothing is uploaded.
- ✓ Formula and method shown above
Provided “as is” for general information only — results may be inaccurate, so verify before you rely on them. No warranty; use at your own risk.
Built and reviewed by HIFreeTools against the formula shown above and any authoritative references cited on this page. See our methodology and editorial standards.
Related tools
- Distance Between Two Points CalculatorCalculators
- GPS Coordinate FinderGeography & Maps
- Pythagorean Theorem CalculatorCalculators
- Map Distance CalculatorGeography & Maps
Embed this tool on your site
Free to embed, no sign-up. Paste this code where you want the haversine distance calculator to appear: