This distance calculator finds the distance between two points on a graph in 2D or 3D, or between two places on Earth using latitude and longitude. For places, it gives the great-circle distance in kilometers, miles and nautical miles, with the starting compass bearing.
Distance formulas
2D: d = √((x₂ − x₁)² + (y₂ − y₁)²)
3D: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
On Earth (haversine formula): a = sin²(Δφ/2) + cos φ₁ × cos φ₂ × sin²(Δλ/2), and d = 2R × asin(√a), where φ is latitude, λ is longitude and R is the Earth’s mean radius of about 6,371 km.
Worked example
New York (40.7128, −74.0060) to London (51.5074, −0.1278) is about 5,570 km (3,461 miles) in a straight line over the Earth’s surface, starting on a bearing of about 51° (north-east).
In 2D, the distance from (1, 2) to (4, 6) is √(3² + 4²) = 5.
Finding latitude and longitude
In most map apps, press and hold (or right-click) a place to see its coordinates. Use decimal degrees, with negative numbers for south latitudes and west longitudes.
Frequently asked questions
Why is the flight distance different?
This is the shortest path over the Earth’s surface. Real flights follow air routes and winds, and road distances follow roads, so both are usually longer.
Why not use the flat distance formula for places on Earth?
Because the Earth is curved. Over long distances, the flat formula gives large errors, while the haversine formula follows the curve.
How accurate is the haversine formula?
Within about 0.5% for most distances, because it treats the Earth as a perfect sphere. Survey-grade tools use an ellipsoid model.
Is the distance formula related to Pythagoras?
Yes. The 2D distance formula is the Pythagorean theorem applied to the horizontal and vertical differences.
Related calculators
Last reviewed: October 2026.