3D Distance Calculator - Formula, Midpoint, Diagonal

Use this 3d distance calculator to find the Euclidean distance between two 3D points, with per-axis differences, midpoint, and squared distance.

3D Distance Calculator

x-coordinate of the first point in 3D space.

y-coordinate of the first point in 3D space.

z-coordinate of the first point in 3D space.

x-coordinate of the second point in 3D space.

y-coordinate of the second point in 3D space.

z-coordinate of the second point in 3D space.

Results

Distance (d)
0units
Δx (x₂ − x₁) 0units
Δy (y₂ − y₁) 0units
Δz (z₂ − z₁) 0units
Squared distance (d²) 0units²
Midpoint x 0units
Midpoint y 0units
Midpoint z 0units

What Is a 3D Distance Calculator?

A 3D distance calculator finds the straight-line distance between two points in three-dimensional space using the 3D Euclidean distance formula. It is the everyday analytic-geometry tool for the question, "how far apart are (x1, y1, z1) and (x2, y2, z2)?" Type the six coordinates and the page shows the distance, the per-axis differences, the squared distance, the midpoint, and the step-by-step math, so you can check your homework and trust the answer.

  • Math homework and 3D analytic geometry: Confirm a problem that asks for the distance between two points in space, the midpoint of the segment, or the space diagonal of a rectangular box that drops out as a 3D Pythagorean triple.
  • Coordinate geometry and 3D graphing: Plot two points in 3D space, then read the distance and the midpoint in one pass without re-entering numbers into a separate tool.
  • Physics, vectors, and displacement: Compute the magnitude of a 3D displacement vector from its start point to its end point before moving on to forces or velocities.
  • Engineering, CAD, and 3D models: Measure the straight-line distance between two corners of a 3D model, a part, or a rectangular enclosure when you need the space diagonal or a tolerance check.

The 3D distance calculator answers the Euclidean distance question for the spatial case, where every point has exactly three coordinates. If you need the 2D case, want to change the unit, or want to convert between coordinate systems, pair this page with one of the peer calculators below.

If you only have x and y coordinates and your points sit on a flat plane, the 2D Distance Calculator page runs the same sqrt of squared differences on a 2D pair of points.

How the 3D Distance Calculator Works

The page implements the standard Euclidean distance formula in 3D. It takes the two point inputs, builds the per-axis differences, squares and sums them across all three axes, and takes the square root.

d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2)
  • x1, y1, z1: Coordinates of the first point in 3D space.
  • x2, y2, z2: Coordinates of the second point in 3D space.
  • Δx = x2 − x1: Horizontal change between the two points, signed.
  • Δy = y2 − y1: Vertical change between the two points, signed.
  • Δz = z2 − z1: Depth change between the two points, signed.
  • d = sqrt(Δx² + Δy² + Δz²): The Euclidean 3D distance, which is always non-negative.

The same formula works for negative coordinates and decimal coordinates on every axis. Squaring removes the sign of Δx, Δy, and Δz, so the distance is always non-negative no matter which point you call first.

Worked example: a 3D Pythagorean triple

Point 1: (0, 0, 0). Point 2: (1, 2, 2).

Δx = 1 − 0 = 1. Δy = 2 − 0 = 2. Δz = 2 − 0 = 2. d = sqrt(1² + 2² + 2²) = sqrt(1 + 4 + 4) = sqrt(9).

d = 3 units.

The two points form a 1-2-2 / 3 Pythagorean triple in 3D, and the distance comes out to a clean integer. The same shape is a 3D cousin of the 3-4-5 right triangle, which is why this example is a favorite in textbooks.

According to Khan Academy, the distance between two points (x1, y1, z1) and (x2, y2, z2) in three-dimensional space is computed as the square root of (x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2, which extends the Pythagorean theorem to a third axis.

If you would rather treat the segment between the two points as a single vector and read its magnitude, the Vector Magnitude Calculator page runs the same sqrt of squared components on one vector at a time.

Key Concepts Behind the 3D Distance Formula

Four ideas explain why the formula is what it is and what the result really means in 3D space.

3D Pythagorean theorem

The 3D distance formula is the Pythagorean theorem applied twice: once across the x-y plane to get a 2D distance, then again with the z difference to add the depth.

Euclidean distance in 3D

It is the length of the shortest path between the two points: a straight line. Squared differences across all three axes are added before the square root, so the distance is non-negative.

Squared 3D distance

The value under the square root, Δx² + Δy² + Δz², is the squared 3D distance. Physics, statistics, and machine-learning tools often work with the squared distance to skip the square root.

Space diagonal of a rectangular box

When the two points are opposite corners of a rectangular box with edge lengths a, b, and c along the x, y, and z axes, the 3D distance is sqrt(a² + b² + c²). For a 2 x 3 x 6 box, the diagonal is sqrt(49) = 7.

These four concepts are the building blocks of 3D analytic geometry. The distance, the per-axis differences, and the 3D midpoint are enough to reconstruct the segment between the two points in almost any form a textbook will ask for.

When the two points are opposite corners of a rectangular box, the 3D distance is the space diagonal, and the Rectangular Prism Volume Calculator page turns the same three edge lengths into the volume of the box.

How to Use This 3D Distance Calculator

Five short steps cover every common case, from a clean textbook example to negative coordinates on every axis.

  1. 1 Enter x₁, y₁, and z₁: Type the coordinates of the first point in 3D space. The default is (0, 0, 0), the origin, so the example starts from a clean reference point.
  2. 2 Enter x₂, y₂, and z₂: Type the coordinates of the second point. The default is (1, 2, 2) so the example starts as the 1-2-2 / 3 3D Pythagorean triple.
  3. 3 Read the 3D distance: The primary output is the Euclidean 3D distance d, updated as you type. It is the same number whether you swap the two points or not, because squaring removes the sign of each per-axis difference.
  4. 4 Check the per-axis values: Look at Δx, Δy, Δz, the squared distance, and the midpoint coordinates to confirm the arithmetic.
  5. 5 Reset or change units if needed: Click Reset to return to the example. If the answer is in generic units and you want meters or feet, open the Distance Converter in a new tab.

Try the points (-1, -2, -2) and (0, 0, 0). The calculator gives Δx = 1, Δy = 2, Δz = 2, distance 3, midpoint (-0.5, -1, -1), and squared distance 9. The result 3 confirms that the same 1-2-2 triple works for points in the negative octant, not just the positive one.

If your points are given in cylindrical or spherical coordinates instead of Cartesian, the Coordinates Converter page converts the six numbers to x, y, z before you enter them here.

Benefits of Using This 3D Distance Calculator

These benefits matter most when you are working a 3D problem by hand and need a quick, trustworthy check.

  • Skip the arithmetic mistakes: Manual 3D distance problems are easy to get wrong on the squaring step across three axes. The calculator handles the three squarings and the square root so you can focus on setting up the problem.
  • See the full step-by-step math: The page shows Δx, Δy, Δz, the squared distance, and the final d. That makes it a good way to check your own work, not just a way to get a number.
  • Get the 3D midpoint for free: You often need the midpoint of the segment between two 3D points at the same time as the distance. The calculator returns all three midpoint coordinates from the same six inputs.
  • Handle any sign of coordinate: Negative coordinates, decimal coordinates, and points far from the origin on every axis all use the same formula. The page does not require you to pre-process the numbers.
  • Connect to space diagonals and volumes: If your next step is the space diagonal of a rectangular box, the volume of a box from its three edge lengths, or the magnitude of a single 3D vector, the page links out to the relevant peer calculator in the same category.

The page is most useful as a check, not as a replacement for understanding the formula. Use it to confirm a homework answer, sanity-check a CAD measurement, or pre-validate a coordinate pair before you hand it to a longer script.

When the 3D distance reduces to a single 1D change, the Right Triangle Calculator page fills in the missing leg, hypotenuse, or angle of the right triangle the difference describes.

Factors That Affect the 3D Distance Result

The formula is the same in every case, but a few factors change how the result should be read.

Order of the two points

Swapping the two points flips the sign of all three per-axis differences, which leaves the squared values, the distance, and the midpoint unchanged. The midpoint is unique regardless of which endpoint you call first.

Coordinate scale and unit

The result is in the same unit as the coordinates. If x, y, and z are in centimeters, d is in centimeters. If you need meters, feet, or another length unit, use the Distance Converter on the result.

Numerical precision of the inputs

Very small rounding in any of the six coordinates can shift the fourth decimal place of d. Enter coordinates with as much precision as the original problem gives.

One-axis change edge case

When two of the three per-axis differences are zero, the 3D distance reduces to the absolute value of the third difference. The page still shows the zeros so the user can confirm the reduction.

Sign of the coordinates

Negative coordinates on any axis work the same as positive coordinates because the formula squares Δx, Δy, and Δz before adding. The result is always non-negative.

  • This page is the 3D Euclidean case only. For 2D points, use the dedicated 2D distance calculator; for distance on a curved surface, the great-circle distance formula is different.
  • The calculator assumes a flat Euclidean space. It does not account for distance on the surface of a sphere (great-circle distance) or along a road network (Manhattan distance), both of which are non-Euclidean metrics.
  • The result is the straight-line distance, not the path length. If the two points lie on a 3D curve, the straight-line distance is a lower bound on the path length, not the path length itself.

According to Wolfram MathWorld, the Euclidean distance between two points in n-dimensional space is the square root of the sum of the squared coordinate differences, so the 3D case is d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2).

If the answer is in generic units and you want meters, feet, miles, or another length unit, the Distance Converter page changes the unit of the result without recomputing the formula.

3d distance calculator showing two points in 3D space, the 3D Euclidean distance formula, and the step-by-step calculation result
3d distance calculator showing two points in 3D space, the 3D Euclidean distance formula, and the step-by-step calculation result

Frequently Asked Questions

Q: What is the formula for the distance between two points in 3D?

A: The formula is d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2). Subtract the x-coordinates, y-coordinates, and z-coordinates, square the three differences, add them, and take the square root.

Q: How do I calculate the distance between two points in 3D space?

A: Enter the coordinates of the first point as x1, y1, and z1, then the coordinates of the second point as x2, y2, and z2. The calculator returns the Euclidean 3D distance, the per-axis differences, the squared distance, and the 3D midpoint in one pass.

Q: What is the difference between the 2D and 3D distance formulas?

A: The 2D formula is d = sqrt((x2 - x1)^2 + (y2 - y1)^2). The 3D formula adds a third squared term for the z difference, giving d = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2). On a flat surface, the 3D formula with z1 = z2 = 0 reduces to the 2D formula.

Q: Can the 3D distance between two points ever be negative?

A: No. The 3D distance is a length, so it is always non-negative. Squaring the per-axis differences makes the under-the-root value non-negative, and the principal square root is non-negative too.

Q: What happens if both points are the same in the 3D distance calculator?

A: If x1 equals x2, y1 equals y2, and z1 equals z2, all three per-axis differences are zero, the squared distance is zero, and the distance is exactly 0. The midpoint equals the original point.

Q: How accurate is the 3D distance calculator?

A: The result is exact up to the displayed four-decimal precision. Because the underlying formula is a direct extension of the Pythagorean theorem to a third axis, there is no approximation in the math itself; any small difference comes from rounding the final number for display.