Distance Calculator

Find the distance between two points on a 2D plane, in 3D space, by latitude and longitude, or between two places on a live road map.

2D distance

Distance between two points (x, y) on a flat plane.

Point 1
Point 2
Result will appear here.

3D distance

Distance between two points (x, y, z) in three-dimensional space.

Point 1
Point 2
Result will appear here.

Distance by latitude & longitude

Shortest (great-circle) distance between two points on Earth's surface, given in decimal degrees.

Point 1
Point 2
Result will appear here.

Distance on a road map

Search two places, or click the map to drop pins. Shows the straight-line distance and, where a route can be found, the driving distance and time.

Tip: click anywhere on the map to set point A, then click again to set point B. Drag either pin to fine-tune it.

Need to know how far apart two points, two cities or two addresses are?

This distance calculator answers four kinds of distance question in one place: the straight-line distance between two points on a 2D graph, the distance between two points in 3D space, the great-circle distance between two latitude and longitude coordinates, and the distance by road between two places on a map.

Pick the tool that fits your question, enter your values and press Calculate.

Calculating Distance Between Points

In Two Dimensions

To measure the straight-line distance between two points on an x-y plane, use:

d = √[(x₂ − x₁)² + (y₂ − y₁)²]

Here, (x₁, y₁) and (x₂, y₂) represent the two points. It doesn’t matter which point you label as “first” or “second” the result stays the same as long as you keep the x and y values matched to the correct point.

Worked example: Find the distance between (1, 5) and (3, 2).

d = √[(3−1)² + (2−5)²] = √[4 + 9] = √13

Swapping the point labels gives the identical answer, since squaring removes the effect of sign.

In Three Dimensions

The same idea extends to 3D space by adding a z-coordinate:

d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]

Worked example: Distance between (1, 3, 7) and (2, 4, 8):

d = √[1² + 1² + 1²] = √3


Measuring Distance Across the Globe

Straight-line geometry doesn’t directly apply to a curved surface like the Earth, so two specialized formulas are commonly used instead.

The Haversine Method

This formula estimates the shortest path between two latitude/longitude points assuming the Earth is a perfect sphere.

It calculates what’s called the great-circle distance the shortest arc connecting two points along a sphere’s surface, traced by the plane that cuts through the sphere’s center.

Because the Earth actually bulges slightly at the equator (its radius is about 6,378 km there, versus roughly 6,357 km at the poles), treating it as a perfect sphere introduces a margin of error typically up to 0.5%.

Lambert’s Formula (Ellipsoidal Method)

To correct for the Earth’s slightly flattened shape, Lambert’s formula treats the planet as an ellipsoid rather than a sphere.

This approach is significantly more accurate  typically within about 10 meters, even across distances spanning thousands of kilometers.

The formula incorporates:

  • a  the Earth’s equatorial radius
  • σ  the central angle between the two points (often derived using the haversine calculation)
  • f  the Earth’s flattening coefficient
  • Correction terms X and Y, which account for how latitude affects the ellipsoid’s curvature

These correction terms rely on “reduced latitude” values (β), computed from each point’s actual latitude (ϕ) adjusted by the flattening factor.

A Note on Accuracy

It’s worth remembering that no formula gives a truly exact answer. Both haversine and Lambert’s formula are mathematical models of the Earth’s shape, and neither accounts for real-world surface variation mountains, valleys, coastlines, or elevation changes.

They calculate distance across an idealised, smooth reference shape, not the bumpy actual terrain. Lambert’s formula simply gets closer to reality by using a more accurate baseline shape (an ellipsoid) instead of a rough approximation

How to Use the Distance Calculator

The calculator has four tools, one for each kind of distance question:

  • 2D distance finds the straight-line distance between two points on a flat graph, from their (x, y) coordinates.
  • 3D distance adds a third coordinate (z), for points in space, such as in physics, 3D modelling or game design.
  • Latitude and longitude gives the shortest distance over the Earth’s surface between two places, often called the “as the crow flies” or great-circle distance.
  • Road map finds a driving route between two places, which is nearly always longer than the straight-line distance.

The Distance Formula, With Worked Examples

For two points on a flat plane, the distance comes straight from Pythagoras’ theorem:

d = √[(x₂ − x₁)² + (y₂ − y₁)²]

Example: from (1, −3) to (7, 5). The horizontal gap is 7 − 1 = 6 and the vertical gap is 5 − (−3) = 8. So d = √(6² + 8²) = √(36 + 64) = √100 = 10.

In three dimensions you add one more squared difference:

d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]

Example: from (1, 2, 1) to (4, 6, 3). The gaps are 3, 4 and 2, so d = √(9 + 16 + 4) = √29 ≈ 5.385.

The order of the points doesn’t matter, because each difference is squared. Watch the signs with negative coordinates, though: subtracting a negative number adds it.

Distance Between Two Places on Earth

A flat formula doesn’t work on a globe.

For latitude and longitude the calculator uses the haversine formula, which treats the Earth as a sphere with a radius of about 6,371 km (3,959 miles) and finds the shortest path along its surface.

Here are some well-known distances worked out that way:

From – toGreat-circle distance
London – New Yorkabout 5,570 km (3,461 miles)
Los Angeles – New Yorkabout 3,936 km (2,446 miles)
Sydney – Aucklandabout 2,156 km (1,340 miles)
London – Edinburghabout 534 km (332 miles)

Because the Earth is slightly flattened at the poles, very precise survey tools can differ from these figures by a few kilometres. For trip planning and everyday questions, the spherical figure is accurate enough.

Why the Road Distance Is Longer

Roads bend around hills, rivers, cities and borders, so a driving route is nearly always longer than the straight-line distance, often by a fifth or more, and by much more in mountains or around coastlines.

Use the great-circle figure for flights and rough comparisons, and the road map tool when you need to know how far you’ll actually drive. For fuel, plug the road distance into the Fuel Cost Calculator.

More Distance Questions

Is the distance between two points ever negative?

No. Distance is always zero or positive, because the differences are squared before the square root is taken.

What’s the difference between distance and displacement?

Distance is how far you travel along your path. Displacement is the straight line from start to finish, with a direction. Walk 3 km east and then 4 km north, and you’ve covered 7 km but your displacement is 5 km.

How do I convert kilometres to miles?

Divide kilometres by 1.609344, or multiply by about 0.6214. The Miles to KM Converter does it both ways.

More free tools from our Everyday Calculators collection:

Tahir Mehmood

About the author

Tahir Mehmood

Tahir Mehmood is the founder of Digital Designs SEO LTD, a UK company, with five years of hands-on experience in SEO, content writing and web development. He builds and maintains the calculators on All in Calculators and keeps them up to date. Spotted an error? Contact us and we will fix it.

Last updated: 27 November 2026