Distance and Midpoint Formula Calculator

Plug in two points to get the straight-line distance, the midpoint and the slope, with every step.

What do you want to work out?

Free, no signup. Everything is worked out in your browser and nothing you type is sent to us.

Distance between the points

How far apart, and where is the middle?

The distance formula gives the straight-line distance between two points on a graph. The midpoint formula gives the point exactly halfway between them. Together they come up in geometry homework, in game and map coding, and in any job where you plot points and need to measure between them.

Enter two points in two or three dimensions and this calculator gives the distance, the midpoint and, in 2D, the slope of the line through them. A third mode measures the distance between two places on Earth from their latitude and longitude.

How to use it

  1. Choose two points in 2D, two points in 3D, or two places.
  2. Enter the coordinates. Negative numbers and decimals are fine.
  3. For places, enter latitude and longitude in decimal degrees: north and east are positive, south and west negative.
  4. Read the distance and the midpoint, then follow the working.

The distance and midpoint formulas

d = √((x2 − x1)² + (y2 − y1)²)
in 3D, add (z2 − z1)² under the square root
midpoint = ((x1 + x2) ÷ 2, (y1 + y2) ÷ 2)

The distance formula is Pythagoras in disguise. The difference in x and the difference in y are the two short sides of a right triangle, and the distance is its longest side. The midpoint is simply the average of the two x values and the average of the two y values.

For places on Earth, a flat formula would be badly wrong over long distances, so the calculator uses the haversine formula. It measures along the surface of a sphere with the Earth's average radius of about 6,371 km.

Worked example: (1, 2) to (4, 6)

  • Differences: x is 4 − 1 = 3, y is 6 − 2 = 4
  • Squares: 3² + 4² = 9 + 16 = 25
  • Distance: √25 = 5
  • Midpoint: ((1 + 4) ÷ 2, (2 + 6) ÷ 2) = (2.5, 4)

The points are 5 units apart and the midpoint is (2.5, 4). The slope of the line through them is 4 ÷ 3, about 1.3333. For places, London (51.5074, −0.1278) to New York (40.7128, −74.006) comes out at about 5,570 km.

Quick checks with whole-number triangles

Differences that give whole-number distances
Difference in xDifference in yDistance
345
51213
6810
81517
72425

If your differences match a row, the distance is a whole number, which makes a handy check on homework.

Common slips

  • Forgetting to square negative differences. (−3)² is 9, not −9. Distances are never negative.
  • Adding before squaring. √(3 + 4) is not the distance; square each difference first.
  • Mixing up the order of a point. Keep x first and y second for both points.
  • Using flat distance for long journeys. Over hundreds of kilometres, the Earth's curve matters. For slopes and line equations, the slope calculator goes further.

Frequently asked questions

What is the distance formula?

For two points (x1, y1) and (x2, y2), the distance is the square root of (x2 − x1)² + (y2 − y1)². It comes from Pythagoras: the differences in x and y form a right triangle, and the distance is its longest side. In 3D, you add (z2 − z1)² under the root.

How do I find the midpoint between two points?

Average the x values and average the y values. The midpoint of (2, 3) and (8, 11) is ((2 + 8) ÷ 2, (3 + 11) ÷ 2) = (5, 7). In 3D, average the z values too. The calculator shows the midpoint with every distance.

What is the haversine formula?

It works out the shortest distance between two places on a sphere from their latitude and longitude, following the curve of the surface. It is a good estimate for distances on Earth. It treats the planet as a perfect sphere, so it can be off by a fraction of a percent compared with survey-grade methods.

Can the distance between two points be negative?

No. The differences can be negative, but squaring makes them positive, and the square root of a positive number is positive. A distance of 0 means the two points are the same. The midpoint, though, can have negative coordinates, for example halfway between (−4, 1) and (2, 3) is (−1, 2).

Related calculators

See all free calculators

More free tools from CloveDesk

CloveDesk gives freelancers and small teams one place for quotes, e-signatures, invoices, files and a portal for each client.

Try CloveDesk free

Last updated: