Distance Formula Calculator

Enter the coordinates of two points and this calculator applies the distance formula d = √((x₂−x₁)² + (y₂−y₁)²) to find the straight-line distance between them — plus Δx, Δy, the distance squared, and the midpoint as a bonus.

Put this calculator on your website — free

Copy one snippet and give your visitors a working Distance Formula Calculator.

How the distance formula calculator works

The straight-line distance between two points looks like a new formula to memorize, but it's a theorem you already know wearing a disguise. Slide from point 1 to point 2 and you can always break the trip into two moves: go sideways by Δx = x₂ − x₁, then straight up or down by Δy = y₂ − y₁. Those two moves are the legs of a right triangle, and the direct diagonal path — the distance you want — is its hypotenuse. Pythagoras handles the rest: square the legs, add, take the root.

The formula

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

d is the distance, (x₁, y₁) and (x₂, y₂) are your two points, and the differences Δx and Δy are the triangle's legs. Because both differences are squared, the order of the points doesn't matter and the result can never be negative.

Worked example

Take the points (0, 0) and (3, 4):

Δx = 3 − 0 = 3 and Δy = 4 − 0 = 4

d = √(3² + 4²) = √(9 + 16) = √25 = 5

This is the famous 3-4-5 right triangle — legs of 3 and 4, hypotenuse of exactly 5. It's the smallest right triangle with all whole-number sides, which is why math teachers reach for it constantly. The midpoint of the trip, for the record, sits at (1.5, 2).

Why d² is sometimes more useful than d

Notice the calculator also reports the distance squared. That's not padding — in a lot of real work, d² is the number you actually want. Square roots are irrational for most inputs (√2, √5, √13...), but the squared distance of integer coordinates is always a clean integer. And if you're only comparing distances — which point is closest? — comparing squared distances gives the same answer while skipping the square root entirely, which is exactly what game engines and mapping software do millions of times per second. Take the root only when you need the distance itself, in actual units.

Frequently asked questions

What is the distance formula?

The distance between two points (x₁, y₁) and (x₂, y₂) is d = √((x₂−x₁)² + (y₂−y₁)²). Subtract the x-coordinates, subtract the y-coordinates, square both differences, add them, and take the square root of the sum.

How is the distance formula related to the Pythagorean theorem?

It is the Pythagorean theorem. The horizontal change Δx and vertical change Δy form the two legs of a right triangle, and the straight line between your points is its hypotenuse. So d² = Δx² + Δy² is just a² + b² = c² in coordinate clothing.

Does it matter which point I call point 1?

No. Swapping the points flips the signs of Δx and Δy, but both differences get squared, and squaring erases the sign. (3−0)² and (0−3)² are both 9, so the distance comes out identical either way.

Can the distance between two points be negative?

No. Squares are never negative and the square root of a non-negative number is non-negative, so distance is always zero or positive. A distance of exactly zero means the two points are the same point.

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

Extend the same pattern with a third term: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²). The Pythagorean idea stacks: you apply it once in the flat plane and once more to include the vertical difference.

Related calculators