CalculateItNow home

Distance Calculator

Straight-line distance between two points in 2D or 3D from their coordinates, with Manhattan distance, midpoint and the Pythagorean working shown.

Distance Calculator: with the default inputs, distance (straight line) is 5.

Try an example
Distance (straight line)
5
Manhattan distance
7
Midpoint
(2.5, 4)
Δx
3
Δy
4
Δz
Assumptions
  • Coordinates are on a flat (Cartesian) grid in consistent units; the result is in those same units.
  • Δz is blank in 2D mode.
Math verified by automated testsUpdated 2026-09-082 sources cited

How this is worked out

The formula

2D:  d = √((x₂ − x₁)² + (y₂ − y₁)²)
3D:  d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
Manhattan:  |x₂ − x₁| + |y₂ − y₁| (+ |z₂ − z₁|)
Midpoint:  ((x₁ + x₂)/2, (y₁ + y₂)/2 (, (z₁ + z₂)/2))

Open How it’s calculated above to see this worked through with your own numbers.

What you enter

Dimensions
Choose one of 2 options.2D (x, y) · 3D (x, y, z)
x₁
A number.defaults to 1
y₁
A number.defaults to 2
z₁ (3D only)
A number.defaults to 0
x₂
A number.defaults to 4
y₂
A number.defaults to 6
z₂ (3D only)
A number.defaults to 0

What you get back

Distance (straight line)main answer
Manhattan distance
Sum of the absolute coordinate differences — the distance walking along a grid.
Midpoint
Δx
Δy
Δz

What this assumes

  • Coordinates are on a flat (Cartesian) grid in consistent units; the result is in those same units.
  • Δz is blank in 2D mode.

About this calculator

The distance formula is the Pythagorean theorem wearing coordinates. Two points on a plane are the ends of a hypotenuse whose legs are the horizontal gap Δx and the vertical gap Δy, so the straight-line distance is √(Δx² + Δy²). In three dimensions you add a third leg, Δz², under the root — nothing else changes.

How to use it

Choose 2D or 3D and type the coordinates. The z-boxes are ignored in 2D mode. The result is the Euclidean (straight-line, "as the crow flies") distance; you also get the Manhattan distance, the midpoint, and each coordinate difference so you can check the arithmetic.

Euclidean vs. Manhattan

If you can only travel along grid lines — city blocks, a chessboard rook, some routing problems — the relevant distance is |Δx| + |Δy|, named after Manhattan's street grid. It's always at least as large as the straight-line distance and equal only when the points share a row or column. From (1, 2) to (4, 6) the crow flies 5 blocks; a taxi drives 7.

Midpoint

The point halfway along the segment is simply the average of the coordinates. It's the centre of a circle whose diameter is the segment, and a common first step in geometry proofs.

Signs don't matter

Δx and Δy can be negative depending on which point you call "first", but squaring removes the sign, so the distance is the same either way. The midpoint is symmetric too. This is why the order of the points never affects the results.

Common mistakes

  • Adding Δx and Δy without squaring (that's the Manhattan distance, not the straight-line one).
  • Squaring the sum instead of summing the squares: (Δx + Δy)² ≠ Δx² + Δy².
  • Forgetting the final square root — 25 is the squared distance, 5 is the distance.
  • Using this on latitude/longitude. Degrees aren't a flat grid; great-circle distance needs the haversine formula.

Frequently asked questions

What is the distance formula?

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

How do I find the distance between two points in 3D?

Add the squared z-difference under the root: d = √(Δx² + Δy² + Δz²). From the origin to (2, 3, 6) that's √(4 + 9 + 36) = 7.

What's the difference between Euclidean and Manhattan distance?

Euclidean is the straight line; Manhattan is the sum of the horizontal and vertical gaps, as if you had to travel along a grid. Manhattan is always ≥ Euclidean.

Does it matter which point I call point 1?

No. Swapping the points changes the signs of Δx and Δy, but squaring removes the signs, so the distance and midpoint are identical.

Put this calculator on your own site

A working distance, free for any site, with no ads and no sign-up. It resizes to fit wherever you paste it and updates itself as this page improves.

Paste this anywhere. It works on any site, carries no ads, never expires, and always shows the current version.

Distance Calculator by CalculateItNow

The page's own title. The clearest description of what the link leads to.

The credit line sits outside the widget on purpose, so it is a real link on your page rather than one buried in a frame. Please keep it — it is what pays for CalculateItNow staying free and ad-free. The script only resizes the widget to fit its contents; drop it and the widget still works.

Browse every calculator widget·How to add it to WordPress, Squarespace or Wix

The questions people ask next to a distance.

All math calculators·Browse everything