Distance CalculatorFree online math calculator — instant results, no sign-up

Distance between two points in 2D or 3D.

Inputs

Distance
5
Midpoint(1.5, 2, 0)

Sign in to save results and favorites.

About the Distance Calculator

This calculator computes the straight-line Euclidean distance and the midpoint coordinates between two points in either two-dimensional or three-dimensional space. It is commonly used by students, engineers, and programmers working with coordinate geometry, spatial mapping, or computer graphics. Setting the z-coordinates to zero allows for standard 2D plane calculations.

x₁
X-coordinate of the first point, unitless or any length unit, typically between -10,000 and 10,000
y₁
Y-coordinate of the first point, unitless or any length unit, typically between -10,000 and 10,000
z₁
Z-coordinate of the first point, set to 0 for 2D calculations, typically between -10,000 and 10,000
x₂
X-coordinate of the second point, unitless or any length unit, typically between -10,000 and 10,000
y₂
Y-coordinate of the second point, unitless or any length unit, typically between -10,000 and 10,000
z₂
Z-coordinate of the second point, set to 0 for 2D calculations, typically between -10,000 and 10,000

Formula and method

Distance = √((x₂ - x₁)² + (y₂ - y₁)² + (z₂ - z₁)²)
Midpoint = ((x₁ + x₂) / 2, (y₁ + y₂) / 2, (z₁ + z₂) / 2)
  • x₁, y₁, z₁Coordinates of the starting point
  • x₂, y₂, z₂Coordinates of the ending point
  • DistanceStraight-line Euclidean distance between the two points
  • MidpointCoordinate point located exactly halfway along the segment connecting both points

The calculator computes the differences along each coordinate axis and evaluates the square root of their sum of squares using Math.hypot. The midpoint is determined by taking the arithmetic mean of each coordinate pair. Final numerical values are rounded to a maximum of 6 significant figures.

Worked example

These are the calculator's starting values and the results it actually produces for them.

Inputs

  • x₁0
  • y₁0
  • z₁0
  • x₂3
  • y₂4
  • z₂0

Results

  • Distance5
  • Midpoint(1.5, 2, 0)

How to use the Distance Calculator

  1. 1Subtract each coordinate of the first point from the corresponding coordinate of the second point to find Δx, Δy, and Δz.
  2. 2Square each difference, sum them together, and take the square root to calculate the distance.
  3. 3Add the corresponding coordinates of both points together and divide each sum by 2.
  4. 4Format the resulting distance and combine the averaged coordinates into the midpoint triplet (x, y, z).

Reading your result

The Distance output represents the shortest path length between the two points in Cartesian space, sharing the same units as the input coordinates. The Midpoint output gives the exact coordinate position equidistant from both points along the straight connecting line segment.

Limitations

This calculator operates strictly in flat Cartesian coordinate systems (Euclidean space) and does not calculate great-circle distances along curved surfaces like the Earth. It also treats all coordinate axes as sharing identical measurement scales and units.

Common questions

How do I use this calculator for 2D coordinates?+

Leave both z₁ and z₂ set to 0. The calculator will compute the standard 2D distance and midpoint in the XY plane.

Does swapping the two points change the distance?+

No. Swapping the first point and the second point yields the exact same distance and midpoint because differences are squared and additions are commutative.

Can I enter negative coordinates?+

Yes. The formulas account for negative values, and the distance calculation squares the differences, ensuring distance is always non-negative.

Does the calculator save my information?+

Calculations run in your browser. While signed in, inputs and results are automatically recorded in account history; saving a result creates a separate saved record.

Further reading

You might also like

Results are estimates for informational purposes and are not financial, medical or legal advice.