Distance Calculator

Find the distance and midpoint between two points in 2D or 3D coordinates.

Your numbers

Live

Instant result. Updates while you type.

Your result

Updated now
—

Enter your numbers.

Distance formula calculator for 2D and 3D points

Enter two coordinate points and choose 2D or 3D. HitEquals reports straight-line distance, coordinate differences, squared distance and the midpoint.

Editorial checkCoordinate formula and midpoint method checked against OpenStax algebra texts. Flagship guide, worked checks and page-specific explanatory diagram reviewed September 13, 2026.Updated September 13, 2026Read the publication standard

Inputs used by this calculator

Distance Calculator uses the fields below. The starting values reproduce the page example; replace them with values from the same units and time period before using the result.

Field-by-field reference for Distance Calculator.
InputStarting exampleAccepted valueHow it is used
Coordinate space2D — x and y2D — x and y · 3D — x, y and zSupplies the coordinate space quantity used by the published equation or result breakdown.
First point x₁2Any finite number supported by the formulaSupplies the first point x₁ quantity used by the published equation or result breakdown.
First point y₁1Any finite number supported by the formulaSupplies the first point y₁ quantity used by the published equation or result breakdown.
First point z₁0Any finite number supported by the formulaSupplies the first point z₁ quantity used by the published equation or result breakdown.
Second point x₂6Any finite number supported by the formulaSupplies the second point x₂ quantity used by the published equation or result breakdown.
Second point y₂4Any finite number supported by the formulaSupplies the second point y₂ quantity used by the published equation or result breakdown.
Second point z₂0Any finite number supported by the formulaSupplies the second point z₂ quantity used by the published equation or result breakdown.
Coordinate differences form a right triangleHorizontal and vertical changes are the legs; straight-line distance is the hypotenuse.P₁P₂d = √(Δx² + Δy²)
Coordinate differences form a right triangleHorizontal and vertical changes are the legs; straight-line distance is the hypotenuse.

Distance between two points

Subtract matching coordinates, square each difference, add the squares and take the positive square root. Squaring removes direction, so reversing the two points gives the same distance.

Distance formula

The 2D formula follows from the Pythagorean theorem. Three dimensions add the squared z difference.

d₂D = √((x₂−x₁)² + (y₂−y₁)²)d₃D = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²)

Midpoint

Average each coordinate separately. The midpoint lies halfway along the segment and is shown with the result.

midpoint = ((x₁+x₂)/2, (y₁+y₂)/2, (z₁+z₂)/2)

Units and coordinate systems

The answer uses coordinate units. Do not mix feet and meters or coordinates from different map projections without converting them first.

Worked example

For (2,1) and (6,4), the changes are 4 and 3. Their squared sum is 25, so distance is 5 and midpoint is (4,2.5).

Straight-line distance versus route distance

Coordinate distance connects two points with one straight segment. It does not follow streets, terrain or the curved surface of Earth. Driving, walking and geographic distance require route or geodesic data rather than this Cartesian formula.

How to verify coordinate inputs

Confirm that both points use the same axis order, scale and origin. A swapped x/y coordinate or a mix of feet and meters can produce a valid-looking number for the wrong geometry.

  1. Write each point in the same coordinate order.
  2. Subtract matching coordinates.
  3. Check the squared differences shown in the result.
  4. Recalculate the midpoint by averaging each pair.

Distance workflow

The same steps extend to z in 3D.
Step2D operation
DifferencesΔx=x₂−x₁; Δy=y₂−y₁
Squared distanceΔx²+Δy²
Distancepositive square root
Midpointaverage each coordinate

Distance formulas by setting

Choose the formula that matches the geometry represented by the inputs.
SettingKnown valuesRelationship
Number linex₁, x₂|x₂−x₁|
2D Cartesianx and y pairs√(Δx²+Δy²)
3D Cartesianx, y and z pairs√(Δx²+Δy²+Δz²)
Road or trailnetwork pathRoute calculation required
Earth surfacelatitude/longitudeGeodesic model required

Frequently asked questions

What is the distance formula?

It is the square root of the sum of squared coordinate differences.

Can distance be negative?

No. Geometric distance is the nonnegative length of the segment.

Does point order matter?

No. Reversing the points changes difference signs but not their squares.

How does 3D distance work?

It adds the squared z-coordinate difference before taking the square root.

Does this calculate driving distance?

No. It calculates straight-line coordinate distance, not a route on roads.

Can I use latitude and longitude directly?

Not for reliable surface distance. Geographic coordinates require a spherical or ellipsoidal Earth model.

Why is the midpoint useful?

It identifies the point halfway along the straight segment in the same coordinate system.

What to keep in mind

Coordinates must use the same scale and reference system. In 2D mode, z values are ignored.

Results are rounded for display in US format, with money in dollars and cents; CSV exports keep full calculation precision. This is a calculation summary, not an official certificate.

Sources and references

Manage privacy choices