Distance Between Two Points in 3D Calculator

Find the exact distance between two points (x1,y1,z1) and (x2,y2,z2) in 3D space using the Pythagorean theorem twice, with simplified radical and decimal steps.

Loading calculator…

The 3D distance formula

The distance between two points (x1,y1,z1)(x_1, y_1, z_1) and (x2,y2,z2)(x_2, y_2, z_2) in space is:

d=(x2x1)2+(y2y1)2+(z2z1)2d = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2 + (z_2-z_1)^2}

This is the Pythagorean theorem applied twice. First, project both points onto the xyxy-plane: the horizontal difference Δx=x2x1\Delta x = x_2 - x_1 and depth difference Δy=y2y1\Delta y = y_2 - y_1 form the legs of a right triangle whose hypotenuse is the planar distance Δx2+Δy2\sqrt{\Delta x^2 + \Delta y^2}. Second, that planar distance and the vertical difference Δz=z2z1\Delta z = z_2 - z_1 form a second right triangle — its hypotenuse is the full 3D distance.

Step by step

To find the distance between two points in space:

  1. Subtract the x-coordinates: Δx=x2x1\Delta x = x_2 - x_1.
  2. Subtract the y-coordinates: Δy=y2y1\Delta y = y_2 - y_1.
  3. Subtract the z-coordinates: Δz=z2z1\Delta z = z_2 - z_1.
  4. Square all three differences and add them: Δx2+Δy2+Δz2\Delta x^2 + \Delta y^2 + \Delta z^2.
  5. Take the square root of that sum — simplifying it to a smaller radical when possible, or rounding it to a decimal approximation.
Tip: The order you subtract in doesn't matter — swap which point is "1" and which is "2" and every difference just flips sign, which disappears the moment it's squared.

Worked examples

Example 1 — irrational result, no perfect-square factor to pull out: for (7,4,3)(7,4,3) and (17,6,2)(17,6,2), Δx=10\Delta x = 10, Δy=2\Delta y = 2, Δz=1\Delta z = -1, so d=102+22+(1)2=100+4+1=10510.2470d = \sqrt{10^2+2^2+(-1)^2} = \sqrt{100+4+1} = \sqrt{105} \approx 10.2470.

Example 2 — another irrational, square-free result: for (5,6,2)(5,6,2) and (7,11,13)(-7,11,-13), Δx=12\Delta x = -12, Δy=5\Delta y = 5, Δz=15\Delta z = -15, so d=(12)2+52+(15)2=144+25+225=39419.8494d = \sqrt{(-12)^2+5^2+(-15)^2} = \sqrt{144+25+225} = \sqrt{394} \approx 19.8494.

Example 3 — perfect-square sum, exact whole number: for (0,0,0)(0,0,0) and (1,2,2)(1,2,2), Δx=1\Delta x = 1, Δy=2\Delta y = 2, Δz=2\Delta z = 2, so d=12+22+22=9=3d = \sqrt{1^2+2^2+2^2} = \sqrt{9} = 3 exactly.

Example 4 — identical points: two points with the same xx, yy, and zz coordinates are zero distance apart — every difference is 00, so d=0=0d = \sqrt{0} = 0.

Exact form vs. decimal approximation

Because most coordinate pairs are not a whole number of units apart, the exact 3D distance is usually an irrational number — one that never terminates or repeats as a decimal. This calculator shows both forms: the exact simplified radical (e.g. 105\sqrt{105}), reduced the same way the Simplify Radicals calculator pulls perfect-square factors out of a radicand, and a rounded decimal approximation beneath it (e.g. 10.246951\approx 10.246951) for whichever a problem calls for.

Tip: A distance of exactly 00 means the two points coincide — there's nothing to simplify, and the decimal approximation is omitted since it would just repeat the same whole number.

Related calculators

This calculator is the direct 3D extension of Distance Between Two Points, which finds the same kind of distance on a flat plane (drop the zz-coordinate and the two formulas match exactly). It also shares its formula with the Rectangular Prism calculator's space diagonal — the distance between two opposite corners of a box is l2+w2+h2\sqrt{l^2+w^2+h^2}, the same expression with ll, ww, hh in place of Δx|\Delta x|, Δy|\Delta y|, Δz|\Delta z|. The underlying right-triangle relationship comes from the Pythagorean Theorem calculator, applied twice here instead of once. The same two points also determine a Midpoint — the point exactly halfway between them in space.

Frequently asked questions

What is the 3D distance formula?
The distance dd between two points (x1,y1,z1)(x_1,y_1,z_1) and (x2,y2,z2)(x_2,y_2,z_2) in space is d=(x2x1)2+(y2y1)2+(z2z1)2d = \sqrt{(x_2-x_1)^2 + (y_2-y_1)^2 + (z_2-z_1)^2}. It is the direct 3D extension of the 2D distance formula: one extra squared term, (Δz)2(\Delta z)^2, for the third dimension.
Why does the 3D distance formula apply the Pythagorean theorem twice?
First, the two points project onto the xyxy-plane, and the Pythagorean theorem gives the planar distance Δx2+Δy2\sqrt{\Delta x^2 + \Delta y^2} between those projections. Then that planar distance and the vertical difference Δz\Delta z form a second right triangle, and the Pythagorean theorem applied again gives the final 3D distance (Δx2+Δy2)2+Δz2=Δx2+Δy2+Δz2\sqrt{(\sqrt{\Delta x^2+\Delta y^2})^2 + \Delta z^2} = \sqrt{\Delta x^2+\Delta y^2+\Delta z^2}.
Does it matter which point I call (x1,y1,z1) and which I call (x2,y2,z2)?
No. Swapping the two points flips the sign of Δx\Delta x, Δy\Delta y, and Δz\Delta z, but each difference gets squared immediately afterward, and squaring erases the sign. The final distance comes out identical either way.
What does it mean when the answer is a radical like √105?
Most pairs of points in space do not sit a whole number of units apart, so the distance is an irrational number that never terminates as a decimal. This calculator reports the exact value as a simplified radical (pulling out any perfect-square factor when one exists) alongside a rounded decimal approximation.
When is the 3D distance a whole number?
The distance is a whole number whenever Δx2+Δy2+Δz2\Delta x^2 + \Delta y^2 + \Delta z^2 is a perfect square — for example (0,0,0)(0,0,0) to (1,2,2)(1,2,2) gives 1+4+4=91+4+4=9, and 9=3\sqrt{9}=3 exactly.
How is this related to the space diagonal of a rectangular prism?
They are the same formula. The space diagonal of a rectangular prism with edges ll, ww, hh is l2+w2+h2\sqrt{l^2+w^2+h^2} — exactly the distance between two opposite corners of the box, where l=Δxl = |\Delta x|, w=Δyw = |\Delta y|, and h=Δzh = |\Delta z|.
How is this different from the 2D distance calculator?
The 2D distance calculator finds the distance between two points on a flat coordinate plane, (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2). This calculator adds a third coordinate, zz, for points in space — the formula is identical except for the extra (Δz)2(\Delta z)^2 term under the square root.

Related calculators