# Haversine Distance Calculator

URL: https://hifreetools.com/developer/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.

## 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

- a = sin²(Δlat ÷ 2) + cos(lat₁) × cos(lat₂) × sin²(Δlon ÷ 2)
- c = 2 × atan2(√a, √(1 − a))
- d = R × c, with R = 6,371 km (mean Earth radius); 1 mi = 1.609344 km, 1 nmi = 1.852 km

## Inputs

- Latitude A (°, + north) (-90 to 90); default 40.7128
- Longitude A (°, + east) (-180 to 180); default -74.006
- Latitude B (°, + north) (-90 to 90); default 51.5074
- Longitude B (°, + east) (-180 to 180); default -0.1278

## Worked examples (computed by the page's own function)

- Latitude A (°, + north) = 40.7128, Longitude A (°, + east) = -74.006, Latitude B (°, + north) = 51.5074, Longitude B (°, + east) = -0.1278 → Great-circle distance (km) = 5570.22, Great-circle distance (mi) = 3461.18, Great-circle distance (nautical miles) = 3007.68  (d = 6371 km × 0.87430893 rad = 5570.2222 km)
- Latitude A (°, + north) = 48.8566, Longitude A (°, + east) = 2.3522, Latitude B (°, + north) = 52.52, Longitude B (°, + east) = 13.405 → Great-circle distance (km) = 877.46, Great-circle distance (mi) = 545.23, Great-circle distance (nautical miles) = 473.79  (d = 6371 km × 0.13772772 rad = 877.46333 km)
- Latitude A (°, + north) = 35.6762, Longitude A (°, + east) = 139.6503, Latitude B (°, + north) = -33.8688, Longitude B (°, + east) = 151.2093 → Great-circle distance (km) = 7825.82, Great-circle distance (mi) = 4862.74, Great-circle distance (nautical miles) = 4225.6  (d = 6371 km × 1.2283501 rad = 7825.8186 km)

## Verification

Checked against 14 reference cases (expected values computed independently). Reviewed 2026-10-27. Latest change 2026-10-28: Moved to the schema renderer with a sourced ledger; the output-unit picker became km / mi / nmi modes, and miles and nautical miles now use the exact 1.609344 km and 1.852 km instead of rounded factors.

## FAQ

**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

- [Movable Type Scripts — Calculate distance between latitude/longitude points (haversine)](https://www.movable-type.co.uk/scripts/latlong.html)
- [Wikipedia — Haversine formula](https://en.wikipedia.org/wiki/Haversine_formula)
- [NIST SP 811 — Guide for the Use of the SI (mile and nautical mile factors)](https://www.nist.gov/pml/special-publication-811)

Runs in the browser; nothing is uploaded. Cite as: HIFreeTools, "Haversine Distance Calculator", https://hifreetools.com/developer/haversine-distance-calculator
