Saved

Press the star next to a tool's name to save it.

All my tools

Distance Between Two Points Calculator

Enter the coordinates of two points, and this distance between two points calculator finds the straight-line distance, the midpoint and the slope, in 2D or 3D.

Restored your last values ·

Negative numbers and decimals are fine. Use the same unit for every value.

Your numbers stay in your browser. Nothing is uploaded.

Distance

–

Enter both points and press Calculate.

See full result

A distance between two points calculator tells you how far apart two coordinates are in a straight line. It's one of the first formulas that you meet in coordinate geometry, and it's easy to slip up with signs and square roots when you work it out by hand. Enter the x and y values of each point, and this distance between two points calculator returns the distance at once, along with the midpoint and the slope. Switch to 3D to add a z coordinate. Negative numbers and decimals both work, so it's handy for homework, drawing and simple design problems.

How the distance between two points calculator works

The tool uses the distance formula, which comes straight from the Pythagorean theorem:

  • In 2D: d = √((x₂ − x₁)² + (y₂ − y₁)²)
  • In 3D: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²)
  • Midpoint: the average of each pair of coordinates
  • Slope in 2D: (y₂ − y₁) ÷ (x₂ − x₁)

How to use the calculator

  1. Choose 2D or 3D.
  2. Enter the first point.
  3. Enter the second point.
  4. Press Calculate to see the distance, midpoint and slope.

A worked example

Find the distance between (1, 2) and (4, 6). The change in x is 4 − 1, which is 3. The change in y is 6 − 2, which is 4. Square them to get 9 and 16, and add them to get 25. The square root of 25 is 5. The midpoint is (2.5, 4), found by averaging 1 and 4, and then 2 and 6. The slope is 4 ÷ 3, or about 1.3333. You may recognize the 3-4-5 right triangle, which is hiding in this example.

Why it works

In mathematics, the Euclidean distance between two points is the length of the line segment between them. It can be calculated from the Cartesian coordinates of the points using the Pythagorean theorem, which is why it's occasionally called the Pythagorean distance. Picture a right triangle with the two points at the ends of its longest side. The change in x forms one short side, and the change in y forms the other. The distance that you want is the hypotenuse, so the theorem gives you its length directly.

A 3D example

Let's find the distance from (0, 0, 0) to (2, 3, 6). The changes are 2, 3 and 6, and their squares are 4, 9 and 36. Together, they add up to 49, and the square root of 49 is 7. The formula is the same idea with one more squared term. Each extra dimension simply adds another term under the square root, so three dimensions aren't any harder than two.

Which point comes first?

It doesn't matter. Each difference is squared, so a negative value becomes positive, and the order of the points can't change the answer. The distance from A to B is always equal to the distance from B to A. The midpoint doesn't depend on the order either. The slope also stays the same, because both the top and the bottom of the fraction change sign together.

Working with negative coordinates

Care is needed when a coordinate is negative, since subtracting a negative number is the same as adding. For the points (−2, 3) and (4, −5), the change in x is 4 − (−2), which is 6. The change in y is −5 − 3, which is −8. Squaring those gives 36 and 64, for a total of 100, so the distance is 10. Using this calculator is a good way of checking your signs.

Special cases

  • Same point: the distance is 0.
  • Vertical line: the x values match, so the slope is undefined.
  • Horizontal line: the y values match, so the slope is 0.
  • On an axis: if only one coordinate changes, the distance is just that change, without any sign.

Where it's used

The formula comes up in many areas. Students use it to find the side lengths of shapes on a grid, and to check whether a triangle is isosceles or right-angled. Designers use it to measure between positions on a screen or a drawing. Programmers use it for game movement and for finding the nearest item in a list. In data science, it's a common way of measuring how similar two records are.

What about places on a map?

This calculator assumes a flat grid. The Earth is curved, so latitude and longitude values shouldn't be entered as though they were x and y coordinates, especially over long distances. A degree of longitude also covers less ground as you move away from the equator. For travel between places, use the city distance tool linked below.

Using decimals and large values

You can enter decimal coordinates, such as 2.5 or −0.75, in any box. The result is shown with up to four decimal places. If you need an exact answer for a math class, look at the distance squared row, since the exact distance is the square root of that number.

Common mistakes

  • Forgetting the square root. Adding the squares isn't the final step.
  • Dropping a negative sign. Subtract carefully.
  • Mixing units. Every coordinate must use the same unit.

Check a right triangle with the Pythagorean theorem calculator, find the steepness of a line with the slope calculator, and measure real journeys with the distance calculator between cities.

What next

Use this often? Add Distance Bet to your Home screen.

Frequently asked questions

How does the distance between two points calculator work?

It squares the change in each coordinate, adds them and takes the square root.

What is the distance formula?

In 2D, it's d = √((x₂ − x₁)² + (y₂ − y₁)²).

Does the order of the points matter?

No. The differences are squared, so the answer is the same either way.

Can I use it in 3D?

Yes. Choose 3D, and enter a z value for each point.

Can I use latitude and longitude?

No. It assumes a flat grid, so use a map or city distance tool for places.

What went wrong?

We only receive the reason you pick, never what you typed into the tool.

Thanks for your feedback.

More Math Tools