CalcGallery

Distance Calculator

The straight-line distance between two points in two or three dimensions, with the midpoint, the change in each coordinate and the slope.

Built by AbhiLast reviewed September 23, 2026

P₁P₂

Your numbers

First point
Second point

Result

Distance: 5

Exact arithmetic on the coordinates entered. Nothing is estimated.

Midpoint
(2.5, 4)
Change in x, x₂ − x₁
3
Change in y, y₂ − y₁
4
Slope
1.33333333333
Report a problem with this calculator
Your entries are kept on this device only.

Results follow the mathematical operation and values shown. Check that you selected the intended operation, convention and dataset type before relying on the result. Read the full disclaimer

How to use the Distance Calculator

  1. Choose two or three dimensions.
  2. Enter the coordinates of both points. Negative numbers and zero are fine.
  3. Read the straight-line distance, then the midpoint, the change along each axis and the slope.

The distance formula

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

This is Pythagoras’ theorem on a grid. The change in x and the change in y are the two legs of a right triangle, and the distance between the points is its hypotenuse. The diagram draws that triangle. From (0, 0) to (3, 4) the legs are 3 and 4, so the distance is 5.

Three dimensions

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

Applying Pythagoras twice gives the extra term. First find the diagonal across the floor, then use it with the height to find the diagonal through the room. It is the same calculation as the longest pole that fits in a box.

What else is reported

Units

Coordinates are plain numbers, so the page has no unit switch. If your coordinates are in feet, the distance is in feet. Both points must use the same unit and the same scale on each axis.

With your numbers

  1. d = √((4 − 1)² + (6 − 2)²)
  2. d = √(9 + 16) = 5

Quick reference

Exact arithmetic on the coordinates entered. Nothing is estimated.

Common math examples, worked out with this calculator's starting values.
ExampleDistance
(1, 2) to (4, 6)5
(0, 0) to (3, 4)5
(−3, −4) to (0, 0)5
(−3, −4) to (3, 4)10
(2, 1) to (2, 9), vertical8
(1, 2, 3) to (4, 6, 15)13
(0, 0, 0) to (1, 2, 2)3

Common questions about the Distance Calculator

Does the order of the points matter?
Not for the distance, and not for the midpoint or the slope. Swapping the points changes the sign of each difference, but the differences are squared, so the distance is the same. The change in x and y reported below it do flip sign, since they are measured from the first point to the second.
Can I use this for the distance between two places on a map?
Only over short distances on a flat, square grid. Latitude and longitude are angles on a curved surface, not coordinates on a plane, and a degree of longitude gets shorter towards the poles. Distances between cities need a great-circle formula such as the haversine, which this page does not do.
How do I find the distance in three dimensions?
Choose three dimensions and enter a z for each point. The formula adds one more squared difference under the square root, (z₂ − z₁)². From (1, 2, 3) to (4, 6, 15) the three differences are 3, 4 and 12, and the distance is √169 = 13.
Why is the slope undefined for a vertical line?
Slope is the change in y divided by the change in x. On a vertical line x does not change, so the division is by zero, which has no answer. It is not infinity: a line leaning slightly one way has a huge positive slope, and slightly the other way a huge negative one, so there is no single value to settle on. The distance is still perfectly well defined.

Report a problem with this calculator