Free, forever – no sign-up, calculations stay in your browser. About me →
Utilities · Geometry

Distance calculator.

Find the straight-line distance between two points. Enter the coordinates of each point and the calculator applies the distance formula in 2D or 3D, with the axis differences and midpoint.

By Jean Borg · Founder & developerfreecalculators.pro · Malta · Updated June 2026
2D and 3D distance Axis gaps and midpoint Your data stays private

Two points

Live

Distance is the square root of the squared differences in each axis. Leave the Z values at 0 for a 2D calculation, or set them for 3D.

Distance

5

straight line between the points

Horizontal (dx)3
Vertical (dy)4
Depth (dz)0
Midpoint(2.5, 4, 0)

Computes Euclidean straight-line distance. For distances on Earth, road distance is longer than this. Calculations run in your browser; nothing you enter is stored.

How it works

The distance formula

The straight-line distance between two points is the square root of the sum of the squared differences along each axis. In 2D that is the square root of dx squared plus dy squared, the Pythagorean theorem applied to coordinates; in 3D you add dz squared.

The points (1, 2) and (4, 6) differ by 3 across and 4 up, and the square root of 9 plus 16 is 5, the classic 3-4-5 triangle. Setting the Z values turns the same calculation into a 3D one.

Reference

Distance formula examples.

The straight-line distance between some example point pairs, in 2D and 3D.

Two pointsDistance
(0,0) to (3,4)5
(2,3) to (5,7)5
(0,0) to (5,12)13
(1,1) to (4,5)5
(1,2,3) to (4,6,8)7.071

The full guide

The complete guide to the distance formula.

Where the formula comes from, how 3D extends it, and what it does and does not measure.

From Pythagoras to coordinates

The distance formula is the Pythagorean theorem in disguise. The horizontal and vertical gaps between two points form the legs of a right triangle, and the straight-line distance is the hypotenuse, the square root of the sum of their squares.

That is why the formula squares each difference, adds them, and takes the square root: it is finding the long side of a triangle.

Extending to three dimensions

For points in space you add a third axis. The 3D distance is the square root of dx squared plus dy squared plus dz squared, the diagonal through a rectangular box whose sides are the coordinate differences.

This is used in 3D graphics, engineering and chemistry, wherever points sit in space rather than on a flat plane. Leave Z at 0 and the formula collapses back to 2D.

Midpoint and axis gaps

Alongside the distance, the calculator reports the gap along each axis and the midpoint, the point exactly halfway between the two. The midpoint is just the average of the coordinates, useful for centring and bisecting.

Seeing the individual axis differences also helps you check the result by hand.

Straight line versus travel distance

This is the Euclidean, as-the-crow-flies distance, the shortest possible path. It is not the same as travel distance, which follows roads, nor great-circle distance across the curved surface of the Earth.

For coordinates on a map measured in simple x and y, though, this straight-line distance is exactly right.

The formula

Square root
of the squares.

Distance is the square root of the squared differences in x, y and z; leave z at zero for 2D.

Circumference ›
distance
# Distance formula
2D: d = sqrt(dx^2 + dy^2)
3D: d = sqrt(dx^2 + dy^2 + dz^2)

# (1,2) to (4,6)
sqrt(9 + 16) = 5

Questions

Distance questions.

How do I calculate the distance between two points?

+

Take the difference in x and the difference in y, square both, add them, and take the square root. Enter the coordinates above and the calculator does it, in 2D or 3D.

What is the distance formula?

+

In 2D it is d equals the square root of (x2 minus x1) squared plus (y2 minus y1) squared. In 3D you add (z2 minus z1) squared inside the square root.

How do I calculate 3D distance?

+

Enter the Z coordinate for both points. The calculator adds the squared Z difference before taking the square root, giving the straight-line distance through space.

Is this the driving distance?

+

No. This is the straight-line, as-the-crow-flies distance between coordinates. Road distance follows routes and is longer, and Earth distances need the great-circle formula.

Is this distance calculator free?

+

Yes. It is completely free with no sign-up, and every calculation runs locally in your browser, so nothing you enter is stored or sent anywhere.

About the developer

Jean Borg

Jean builds and maintains every calculator on freecalculators.pro from Malta, with a focus on tools that are fast, free and show their working. The distance calculator applies the 2D and 3D Euclidean distance formula and shows the midpoint.