Distance Between Two Points Calculator
Find the straight-line (Euclidean) distance between any two points in 2D or 3D space. Enter the x, y, and z coordinates of each point — leave z at 0 for a 2D problem.
Distance (2D)
5
- Δx (x₂ − x₁)
- +3
- Δy (y₂ − y₁)
- +4
- Δz (z₂ − z₁)
- 0
- 2D distance (xy plane)
- 5
Euclidean distance: d = √((+3)² + (+4)²) = 5.
How to use this calculator
Enter the x, y, and z coordinates of Point A and Point B. If you only need the 2D distance, leave both z values at 0. The calculator returns the straight-line distance, the deltas in each axis (Δx, Δy, Δz), and the 2D distance in the xy-plane for reference. Coordinates can be positive, negative, or decimal — the math treats them identically.
How the calculation works
The Euclidean distance formula is a direct application of the Pythagorean theorem. In 2D, the distance between (x₁, y₁) and (x₂, y₂) is d = √((x₂ − x₁)² + (y₂ − y₁)²). In 3D, you add the z-axis difference inside the square root: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). The order of the points does not matter — squaring removes the sign, so the distance from A to B is the same as from B to A. This is the shortest possible path between two points in flat (Euclidean) space.
Worked example
Take Point A at (1, 2, 3) and Point B at (4, 6, 8). The deltas are Δx = 4 − 1 = 3, Δy = 6 − 2 = 4, Δz = 8 − 3 = 5. Square each: 9, 16, 25. Sum: 50. Square root: √50 ≈ 7.0711. So the 3D distance is about 7.071 units. If we ignore the z-axis, the 2D distance in the xy-plane is √(3² + 4²) = √25 = 5 — the classic 3-4-5 right triangle.
Frequently asked questions
What is the formula for the distance between two points?
In two dimensions, the distance between (x₁, y₁) and (x₂, y₂) is √((x₂ − x₁)² + (y₂ − y₁)²). In three dimensions, you include the z-axis: √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). This is called the Euclidean distance formula and it comes directly from the Pythagorean theorem — the squared distance is the sum of the squared differences along each axis.
Does the order of the points matter?
No. Because each axis difference is squared inside the formula, the sign drops out: (x₂ − x₁)² = (x₁ − x₂)². The distance from A to B is always equal to the distance from B to A. This is one of the defining properties of a metric — it has to be symmetric.
Can I use this for 2D problems?
Yes. Leave both z-coordinates at 0 (their default). The 3D formula collapses to the 2D formula because the (z₂ − z₁)² term becomes zero. The calculator also shows the 2D distance in the xy-plane separately in the breakdown, so you can see both at once.
Does this work for latitude and longitude?
Not directly. Euclidean distance assumes flat (Cartesian) coordinates, but the Earth is approximately a sphere. For latitude / longitude pairs, you need the haversine formula or the Vincenty formula to account for curvature. Treating lat / long as flat x / y gives reasonable results only for very short distances (a few kilometres) where curvature is negligible.
What units does the result use?
Whatever units you entered. Distance is dimensionally the same as the input coordinates — if you put in metres, you get metres back; if you put in pixels, you get pixels. The calculator does no unit conversion; it just computes the geometric distance.
How does this relate to the Pythagorean theorem?
The 2D distance formula is exactly the Pythagorean theorem applied to a right triangle whose legs are parallel to the x and y axes. The hypotenuse of that triangle is the straight-line distance between the points. The 3D version extends this: you can think of it as applying Pythagoras twice — once in the xy-plane to get the 2D distance, then again with that 2D distance and the z-axis difference as the two legs of a new right triangle.