Free online formula calculators

Distance Formula Calculator

Enter the coordinates of two points to get the straight-line distance between them, in two or three dimensions.

Distance Formula Calculator
Result
Distance10
Distance squared100
Working√(6² + 8²) = √100

Link to this calculation

Formula

d = √((x2 − x1)2 + (y2 − y1)2)
3D: d = √(Δx2 + Δy2 + Δz2)
SymbolMeaning
(x₁, y₁, z₁)Coordinates of the first point
(x₂, y₂, z₂)Coordinates of the second point
dStraight-line distance between the points

How to Use This Calculator

  1. Choose the Dimensions (2D (x, y), 3D (x, y, z)).
  2. Enter the x₁.
  3. Enter the y₁.
  4. Enter the z₁ when Dimensions is 3D (x, y, z).
  5. Enter the x₂.
  6. Enter the y₂.
  7. Enter the z₂ when Dimensions is 3D (x, y, z).
  8. Press Calculate. Results also update automatically as you type.

Worked Example

Using the values pre-filled in the calculator above:

Inputs
Dimensions2D (x, y)
x₁1
y₁2
x₂7
y₂10
Results
Distance10
Distance squared100
Working√(6² + 8²) = √100

About This Calculation

The distance formula is the Pythagorean theorem written in coordinates. The horizontal gap Δx and the vertical gap Δy between two points form the legs of a right triangle, and the straight line joining the points is its hypotenuse. In three dimensions the same idea is applied twice, adding a Δz² term under the square root.

Because the differences are squared, it does not matter which point you call the first: the distance from A to B equals the distance from B to A, and negative coordinates are handled automatically. The result is in the same units as the coordinates, so if your axes are in meters, so is the distance. On a map with latitude and longitude, however, this formula is only an approximation over short ranges — for long distances on the curved Earth you need the great-circle (haversine) formula.

Euclidean distance is used in computer graphics and game collision checks, in GPS and robotics, in CAD and surveying, and in data science, where algorithms such as k-nearest neighbors and k-means clustering measure how "close" two data points are. The squared distance is shown too, since programs often compare squared distances to avoid the cost of a square root.

Frequently Asked Questions

Can the distance ever be negative?
No. It is the square root of a sum of squares, so it is always zero or positive. It is zero only when both points are identical.
What is the midpoint of the same two points?
Average the coordinates: ((x₁ + x₂)/2, (y₁ + y₂)/2). The midpoint calculator does this and also shows the segment length.

Category: Math & Algebra. Found a problem with this calculator? Let us know.