Distance Calculator guide
Distance Calculator: Between Two Points or Two Places
Use our distance calculator to find the distance between two points in 2D or 3D, or between two places using latitude and longitude.
By the AllCalculator editorial teamUpdated 16 October 20261 min read
Our Distance Calculator works out straight-line distances, whether between points on a graph or between two cities.
How to use the calculator (Distance Calculator)
- Choose two points (x, y), two points in 3D or two places (latitude and longitude).
- Enter the coordinates.
The distance formula
For two points on a graph:
d = √((x₂ − x₁)² + (y₂ − y₁)²)
It's Pythagoras' theorem: the difference in x and the difference in y form the two shorter sides of a right-angled triangle. In 3D, add (z₂ − z₁)² inside the square root.
Distance between places
For latitude and longitude, the calculator uses the haversine formula, which gives the shortest distance over the Earth's surface (the great-circle distance). It also gives the initial compass bearing.
Worked examples
- With the calculator's default settings, the distance from (1, 2) to (4, 6) is √(3² + 4²) = 5.
- From London (51.5074, −0.1278) to Edinburgh (55.9533, −3.1883) is about 534km, or 332 miles, as the crow flies.
Frequently asked questions
Why is the road distance longer?
Roads don't go in straight lines. The driving distance from London to Edinburgh is about 400 miles.
Where can I find latitude and longitude?
Most online maps show them when you click or long-press on a place. West of Greenwich, longitude is negative.
How accurate is it?
The haversine formula treats the Earth as a sphere, so it's accurate to about 0.5%.
For the slope and equation of a line through two points, use our Slope Calculator.
Sources and further reading
- GOV.UK: National curriculum in England – mathematicsgov.uk
- Ordnance Survey: A guide to coordinate systems in Great Britainordnancesurvey.co.uk
Links open official and independent websites in a new tab.
This guide is general information to help you understand your options. It isn't financial, tax, legal or building advice and doesn't take your personal circumstances into account. Figures were checked when the guide was last updated and can change, so confirm anything important with GOV.UK, HMRC, a regulated adviser or a qualified tradesperson.