Skip to content

Distance Between Two Points Calculator

Distance

5

Step-by-step
  1. Δx = 3 − 0 = 3
  2. Δy = 4 − 0 = 4
  3. Δx² = 9 Δy² = 16
  4. sum = 25
  5. d = √25 = 5

Estimates for educational purposes — not financial, medical, or legal advice. See terms.

Compute the straight-line distance between two points in 2D or 3D. Type the coordinates, pick the dimension, and the tool applies the Euclidean distance formula and shows the step-by-step working — per-axis differences, squared, summed, and square-rooted.

The formula

For two points p₁ = (x₁, y₁) and p₂ = (x₂, y₂) in 2D, the Euclidean distance is:

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

For 3D with points p₁ = (x₁, y₁, z₁) and p₂ = (x₂, y₂, z₂):

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

Both are the Pythagorean theorem in disguise. In 2D, the two points form a right triangle with legs equal to the axis-aligned differences (Δx and Δy) and the hypotenuse is the distance. In 3D, the three axis differences form an orthogonal triple and the distance is the space diagonal of the implied axis-aligned box.

Example: the classic 3-4-5 right triangle

Point 1 = (0, 0), Point 2 = (3, 4), in 2D mode. Steps:

  1. Δx = 3 − 0 = 3
  2. Δy = 4 − 0 = 4
  3. Δx² = 9, Δy² = 16
  4. sum = 25
  5. d = √25 = 5

That’s the classic Pythagorean triple everyone sees in their first geometry class. The tool handles the whole computation in one go, but the step list lets you see each piece.

Example: a 3D cube diagonal

Point 1 = (0, 0, 0), Point 2 = (1, 1, 1), in 3D mode. This is the body diagonal of a unit cube — the longest straight line inside it. Steps:

  1. Δx = 1, Δy = 1, Δz = 1
  2. Δx² = Δy² = Δz² = 1
  3. sum = 3
  4. d = √3 ≈ 1.732

That √3 is the canonical body-diagonal length for a unit cube, the 3D analogue of √2 for a unit square’s diagonal.

Example: negative coordinates

Point 1 = (−2, −3), Point 2 = (4, 5), in 2D. Steps:

  1. Δx = 4 − (−2) = 6
  2. Δy = 5 − (−3) = 8
  3. Δx² = 36, Δy² = 64
  4. sum = 100
  5. d = √100 = 10

Signs don’t matter after the squaring step — what matters is the magnitude of the differences.

2D vs 3D

The tool defaults to 2D. Toggle to 3D when you need the z coordinate — for example, when computing distances in a 3D model, 3D graphics, or physical space. The 3D formula is a direct extension of the 2D one: add another squared term for z. If you set z₁ = z₂ = 0, the 3D formula reduces exactly to the 2D formula, which is a useful sanity check baked into the test suite.

Dimensions beyond 3 follow the same pattern — 4D distance adds (Δw)², and so on — but the tool doesn’t support them because the use cases are niche and the UI would get unwieldy.

When this formula is the wrong tool

Not every “distance” is Euclidean. A few common cases where you need a different formula:

  • Distances on a sphere (latitude/longitude on the Earth). Use the great-circle (haversine) formula, not Euclidean distance in degrees. Lat/lon are angles, not Cartesian coordinates, and the Earth is curved.
  • Manhattan distance (grid-aligned, taxicab). For counting street blocks in a city grid, use |Δx| + |Δy| — no squaring or square roots.
  • Chebyshev distance (chessboard). For the king’s move in chess, use max(|Δx|, |Δy|).
  • Edit distance for strings. Not a geometric distance at all; use Levenshtein or a similar algorithm.

This tool handles only Euclidean distance in flat Cartesian space. For any other geometry or semantic, use the appropriate dedicated calculator.

What this tool does not do

It doesn’t handle more than 3 dimensions. 4D, 5D, and higher are all valid and follow the same pattern, but the UI stops at 3.

It doesn’t compute distances on a sphere, ellipsoid, or other curved surface. For the Earth’s surface, you need a haversine or Vincenty calculator.

It doesn’t find the distance from a point to a line, plane, or other shape. Those are different formulas (perpendicular projection), not covered here.

It doesn’t parse coordinate strings like “(3, 4)”. Enter x and y separately in the provided fields.

It doesn’t do vector arithmetic — addition, dot product, cross product. For those, you need a vector calculator. For the pure 2D-leg-hypotenuse case (no coordinates, just side lengths), the Pythagoras calculator is the simpler entry point.

Frequently asked questions

What is the distance formula?

For two points in 2D with coordinates (x₁, y₁) and (x₂, y₂), the distance is √((x₂ − x₁)² + (y₂ − y₁)²). In 3D, add (z₂ − z₁)² inside the square root. The formula is just the Pythagorean theorem applied to the right triangle formed by the two points and the line segment connecting them — the axis-aligned differences are the legs and the distance is the hypotenuse. It generalises cleanly to any number of dimensions, though the tool stops at 3.

Does the order of the points matter?

No. Distance is symmetric: the distance from A to B equals the distance from B to A. That's because squaring the difference makes the sign irrelevant — (x₂ − x₁)² is the same as (x₁ − x₂)². So swap the points, the answer doesn't change. The tool does the subtraction in one fixed direction (p₂ − p₁) so the step-by-step output is consistent, but you can feed the points in any order you like.

What if both points are the same?

You get zero. (x₁, y₁) and (x₁, y₁) have zero difference in every axis, so the sum under the square root is zero, and √0 = 0. That's actually a useful sanity check — a distance of zero means you typed the same point twice. The tool handles this case explicitly and doesn't throw.

Does negative coordinates change anything?

No. Negative coordinates work exactly the same way — the subtraction and squaring handle the signs automatically. Distance between (−3, −4) and (0, 0) is √(9 + 16) = √25 = 5, identical to the distance between (3, 4) and (0, 0). What matters is the difference between the coordinates, not their absolute values. A coordinate system with all positive values, all negative values, or a mix all give the same distances for the same relative positions.

Why is this called Euclidean distance?

Because it's the 'straight line' distance in ordinary (Euclidean) flat space, the kind you'd measure with a ruler. It's named after Euclid, the Greek mathematician who formalised plane geometry in the 3rd century BCE. Other distance measures exist for other spaces: Manhattan distance sums the absolute differences (|Δx| + |Δy|, no squaring or square root), Chebyshev distance takes the max, and distances on curved surfaces like the Earth's sphere need great-circle formulas. The distance formula on this page is the Euclidean one, which is what you want for Cartesian coordinates in a flat plane or flat 3D space.