Distance between two points (2D or 3D)

Enter the coordinates of the two points: the page gives the length of the segment joining them.

Distance between two points (2D or 3D)

Dimension

Result

5Distance AB

d = √(3² + 4²) = √25 = 5
Change in x (x₂ − x₁)
3
Change in y (y₂ − y₁)
4
Midpoint
(2.5, 4)

Distance between two points (2D or 3D)

Inputs

Dimension
Plane (2D)
x of point A
1
y of point A
2
x of point B
4
y of point B
6

How it is calculated

Compute the changes Δx = x₂ − x₁, Δy = y₂ − y₁ (and Δz in 3D).

Result

Distance AB

5
Change in x (x₂ − x₁)
3
Change in y (y₂ − y₁)
4
Midpoint
(2.5, 4)

How it is calculated

  1. Compute the changes Δx = x₂ − x₁, Δy = y₂ − y₁ (and Δz in 3D).
  2. Distance = √(Δx² + Δy² + Δz²): this is Pythagoras’ theorem.
  3. Midpoint = average of the two points’ coordinates.

Example

A(1, 2) and B(4, 6): Δx = 3, Δy = 4, d = √(9 + 16) = √25 = 5. Midpoint (2.5, 4).

Good to know

  • This is the straight-line distance in an orthonormal grid, not a road trip.
  • For two cities on Earth you need a distance on the sphere (latitude, longitude), not this formula.
  • Both points must use the same unit.

When to use it

  • Measure the length of a segment from its coordinates in a geometry exercise.
  • Find the midpoint between two points on a plan or a grid.
  • For the slope and equation of the line through the same points, use Slope of a line.

Frequently asked questions

Does the order of the two points matter?

No. Δx and Δy change sign, but they are squared, so the distance is the same.

Can I use it for map coordinates?

Only on a flat plan with the same unit on both axes, such as metres on a site plan. Latitude and longitude are angles, not lengths.

What is the distance in 3D used for?

For example, the diagonal of a box or the length of a cable between two points at different heights. It adds Δz² under the root.

Updated October 10, 2026

Indicative result. For an important decision, check with a professional.