Skip to content

Distance Calculator

Find the straight-line distance between points on a graph or in space, or the great-circle distance between two places on Earth from their coordinates.

MathUpdated Free · No sign-up

How to use the Distance Calculator

  1. Pick what you want to work out using the tabs: 2D points, 3D points or Latitude / longitude.
  2. Enter x₁.
  3. Enter y₁.
  4. Enter x₂.
  5. Enter y₂.
  6. Read your answer in the results panel. It updates as you type, and the breakdown, step-by-step working and any charts or tables appear below it.
  7. Use Share link to save or send the exact calculation, or Copy to paste the results elsewhere.

The distance formula

The distance between two points on a flat graph comes straight from the Pythagorean theorem: the horizontal and vertical differences are the legs of a right triangle and the distance is its hypotenuse.

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

In three dimensions one more term is added: d = √(Δx² + Δy² + Δz²). Example: from (1, 2) to (4, 6) the differences are 3 and 4, so d = √(9 + 16) = 5. From (1, 2, 3) to (4, 6, 15) the differences are 3, 4 and 12, so d = √169 = 13. When the answer is a root that can be simplified, such as √72, the calculator also gives the exact form 6√2.

Distances on the Earth

For two places given by latitude and longitude, the shortest route over the surface is a great-circle arc, not a straight line on a flat map. That is why flights from North America to Europe curve north over the Atlantic. The calculator gives two answers:

  • Haversine treats the Earth as a sphere with mean radius 6,371 km. It is simple and usually within about 0.5% of the true value.
  • Vincenty uses the WGS-84 ellipsoid, the same model GPS uses, which accounts for the Earth being slightly flattened at the poles. It is accurate to well under a meter.

a = sin²(Δφ/2) + cos φ₁ cos φ₂ sin²(Δλ/2), d = 2R·atan2(√a, √(1 − a))

Here φ is latitude and λ is longitude, both in radians. For New York (40.7128, −74.0060) to London (51.5074, −0.1278) the haversine distance is about 5,570 km and Vincenty gives about 5,585 km, roughly 3,470 miles.

Entering coordinates

  • Use decimal degrees. North latitudes and east longitudes are positive; south and west are negative.
  • To convert degrees, minutes and seconds, use degrees + minutes ÷ 60 + seconds ÷ 3600. So 40° 42′ 46″ N is 40.7128.
  • One degree of latitude is about 111 km everywhere. One degree of longitude is 111 km at the equator and shrinks to zero at the poles.

Units

Results are shown in kilometers, statute miles (1.609344 km) and nautical miles (1.852 km). Nautical miles are used at sea and in the air because one nautical mile is very close to one minute of latitude. The initial bearing tells you the compass direction to set off in; on a great circle the bearing changes along the way.

Frequently asked questions

What is the distance formula?

d = √((x₂ − x₁)² + (y₂ − y₁)²). It is the Pythagorean theorem applied to the horizontal and vertical gaps between the points.

Is this the driving distance?

No. It is the shortest distance over the Earth’s surface, as the crow flies. Road distances are usually 20–40% longer.

Which is more accurate, haversine or Vincenty?

Vincenty, because it models the Earth’s real, slightly flattened shape. The difference is usually under 0.5%, which matters for surveying but rarely for travel planning.

How many kilometers are in a nautical mile?

Exactly 1.852 km, or about 1.151 statute miles.