What this calculator does
The distance formula gives the straight-line distance between two points from their coordinates alone, no ruler needed. In two dimensions it is Pythagoras in disguise: the gap in x and the gap in y form the two short sides of a right triangle, and the distance between the points is the hypotenuse. In three dimensions the same idea extends with a third term for the gap in z.
This is a distance calculator for coordinate points specifically, not a unit converter. Enter two points, choose 2D or 3D, and the distance comes back along with the individual x, y (and z) gaps the calculation is built from.
The formula
For two points, the differences in each coordinate are squared, added together, and the square root taken. In 2D that is √((x₂−x₁)² + (y₂−y₁)²); in 3D a (z₂−z₁)² term is added under the same square root. Squaring removes the sign of each difference, so it does not matter which point is labelled 1 and which is labelled 2.
| Term | Meaning |
|---|---|
| Coordinates | The x, y (and z, in 3D) position of each point. |
| Δx, Δy, Δz | The difference between the two points along each axis: the second point's coordinate minus the first. |
| Distance | The straight-line (Euclidean) distance between the two points, the square root of the sum of the squared differences. |
The inputs explained
| Field | What to enter |
|---|---|
| Dimensions | Whether the two points have just x and y coordinates (2D) or also a z coordinate (3D). |
| x₁ | The x coordinate of the first point. |
| y₁ | The y coordinate of the first point. |
| z₁ (3D only) | The z coordinate of the first point, used only in 3D mode. |
| x₂ | The x coordinate of the second point. |
| y₂ | The y coordinate of the second point. |
| z₂ (3D only) | The z coordinate of the second point, used only in 3D mode. |
When to use it
Working the formula for distance by hand
A student checking homework, or anyone who wants to see the formula for distance applied to their own numbers rather than trusting a textbook example, gets every intermediate step: the x gap, the y gap, and the final square root.
Finding distance in 3D space
Coordinates with a z axis show up in 3D modelling, physics problems and some mapping work, and the plain 2D formula does not account for the extra dimension without the added z term.
Checking how far apart two points on a graph are
Given the coordinates of two plotted points, the distance calculator returns the length of the line segment between them without needing to measure the graph itself.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
Distance from the origin to a range of 2D points
The origin against a spread of second points, each a simple whole-number step away.
Adding a third dimension to the same pair of points
The same x and y coordinates, compared with and without a z gap of 5 added in 3D mode.
| Mode | Distance |
|---|---|
| 2D (x, y only) | 5.000 |
| 3D (x, y, z) | 7.071 |
Questions
What is the distance formula?
It is Pythagoras applied to coordinates: d = √((x₂−x₁)² + (y₂−y₁)²) for two points on a plane, with a matching (z₂−z₁)² term added under the root for points in 3D space.
Is a distance calculator the same as a distance converter?
No. A distance converter changes a length from one unit to another, such as miles to kilometres. This calculator works out a straight-line distance between two coordinate points, which is a different, geometric question.
What is the formula for distance in 3D?
d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²), the same squared-differences-under-a-root pattern as 2D, extended with one more term for the z axis.
Does it matter which point is point 1 and which is point 2?
No. Each difference is squared before being added, which removes the sign, so swapping the two points around gives the same distance either way.
For the midpoint, slope and line equation between two points as well as the distance, see the distance, midpoint and slope calculator. For distance and travel time between two named places, see the length and distance converter.