Home / Math Calculators / Distance Calculator
Math & Geometry Tools

Distance Calculator

Calculate the straight-line distance between two points in 2D or 3D space. Find the midpoint, coordinate differences, and a step-by-step solution using the distance formula.

✓ 2D and 3D✓ Midpoint & differences✓ Step-by-step formula
Calculator

Enter two points

Point A
Point B

Coordinates may be positive, negative, or decimal. Both points must use the same coordinate system and unit. This tool calculates straight-line coordinate distance, not driving or road distance.

Quick examples

Your results

Distance and midpoint

Straight-line distance (d)
5.00 units
Horizontal difference (Δx)
3
Vertical difference (Δy)
4
Squared distance (d²)
25
Midpoint
(1.50, 2.00)
Slope (Δy / Δx)
1.33

Coordinate diagram

AB ΔxΔy d xy

Step-by-step solution

1. Δx = 3 − 0 = 3
2. Δy = 4 − 0 = 4
3. d² = 3² + 4² = 25
4. d = √25 = 5 units

Distance formula

The distance formula calculates the straight-line distance between two coordinate points. It follows from the Pythagorean theorem: the coordinate differences form the legs of a right triangle, and the distance is its hypotenuse. Learn more about distance formulas.

2D distanced = √[(x₂ − x₁)² + (y₂ − y₁)²]
3D distanced = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]
Midpoint in 2DM = ((x₁ + x₂) / 2, (y₁ + y₂) / 2)
Squared distanced² = Δx² + Δy² (+ Δz² in 3D)

Example: points (0, 0) and (3, 4)

The horizontal difference is 3 and the vertical difference is 4. Squaring and adding gives 3² + 4² = 9 + 16 = 25. The square root of 25 is 5, so the points are 5 units apart.

Worked calculationΔx = 3 − 0 = 3
Δy = 4 − 0 = 4
d = √(3² + 4²) = √25 = 5 units

How to use this distance calculator

  1. Choose 2D or 3D coordinates.
  2. Enter the coordinates for Point A and Point B. In 3D mode, enter the z-coordinate for each point too.
  3. Select a unit label and decimal precision.
  4. Click Calculate distance to see the distance, midpoint, coordinate differences, and calculation steps.

This calculator handles Cartesian coordinates only. It does not calculate GPS great-circle distance, driving routes, or map distances. Coordinate values must share a consistent scale and unit.

Frequently asked questions

What is the distance formula?

In 2D, the distance formula is d = √[(x₂ − x₁)² + (y₂ − y₁)²]. In 3D, add the squared difference between the z-coordinates inside the square root.

Can I enter negative coordinates?

Yes. Negative, positive, and decimal coordinate values are supported. The result is based on the differences between corresponding coordinates.

What is the midpoint?

The midpoint is the point exactly halfway between two points. In 2D, average the x-coordinates and average the y-coordinates.

Does this calculate driving distance?

No. It calculates straight-line distance between Cartesian coordinates. Driving distance depends on roads and routes and requires a routing or map tool.

What is the difference between 2D and 3D distance?

2D distance uses horizontal and vertical coordinates (x and y). 3D distance also includes depth or height (z).

What if both points are the same?

If both points have identical coordinates, the distance is zero and the midpoint is that same point. The slope is undefined when the horizontal difference is zero.