Distance Calculator

Calculate distance and midpoint between two points in 2D or 3D space.

Results

Distance-
Midpoint-
Formula Used-
Step-by-Step-

What is a Distance Calculator?

A distance calculator finds the straight-line (Euclidean) distance between two points in a coordinate system — the length of the shortest possible path connecting them, as if you stretched a string tightly from one point to the other. This tool works in both 2D (a flat plane with x and y axes) and 3D (space, with a z axis added), and it also computes the midpoint, which is the point exactly halfway between the two endpoints.

Every result includes the formula used and the step-by-step working, so you can follow the math instead of trusting a black box. Coordinate distance comes up constantly in geometry homework, physics, engineering, game development, and mapping — anywhere positions are described numerically and square roots by hand would be slow and error-prone.

The Distance Formula

The distance formula is the Pythagorean theorem applied to coordinates. The horizontal and vertical differences between two points form the two legs of a right triangle, and the distance is the hypotenuse. In 3D, a third perpendicular leg is added to the same pattern:

2D: d = √((x₂−x₁)² + (y₂−y₁)²)

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

The midpoint is even simpler — average the coordinates one axis at a time:

2D: M = ((x₁+x₂)/2, (y₁+y₂)/2)

3D: M = ((x₁+x₂)/2, (y₁+y₂)/2, (z₁+z₂)/2)

  • x₁, y₁, z₁ — the coordinates of the first point (z₁ only in 3D mode).
  • x₂, y₂, z₂ — the coordinates of the second point. The order of the points does not matter, because each difference is squared and (−5)² and 5² both equal 25.
  • d — the straight-line distance, expressed in whatever units your coordinates use (meters, miles, pixels — the math is unit-agnostic).
  • M — the midpoint, the center of the line segment joining the two points.

Worked Example: From (3, 7) to (15, 12)

Suppose you want the distance between Point 1 = (3, 7) and Point 2 = (15, 12) on a 2D plane. Work through the formula piece by piece:

  • Horizontal difference: Δx = x₂ − x₁ = 15 − 3 = 12
  • Vertical difference: Δy = y₂ − y₁ = 12 − 7 = 5
  • Square each difference: 12² = 144 and 5² = 25
  • Add the squares: d² = 144 + 25 = 169
  • Take the square root: d = √169 = 13

The midpoint is ((3 + 15)/2, (7 + 12)/2) = (18/2, 19/2) = (9, 9.5). The clean whole-number answer is no accident: 5, 12, and 13 form a Pythagorean triple, the second most famous right-triangle ratio after 3-4-5.

In 3D the same pattern continues. Between (1, −2, 3) and (3, 1, 9), the differences are Δx = 2, Δy = 3, Δz = 6, so d² = 2² + 3² + 6² = 4 + 9 + 36 = 49 and d = √49 = 7, with midpoint ((1+3)/2, (−2+1)/2, (3+9)/2) = (2, −0.5, 6). Notice the negative coordinate causes no trouble.

Most real problems do not come out this clean. From (0, 0) to (1, 1), for instance, d = √2 = 1.41421356…, which the calculator rounds to 1.4142 — results display four decimal places.

Common Distances at a Glance

Whole-number coordinate differences that produce whole-number distances are called Pythagorean triples — handy for sanity-checking results:

ΔxΔyd² = Δx² + Δy²Distance d
349 + 16 = 255
6836 + 64 = 10010
51225 + 144 = 16913
81564 + 225 = 28917
72449 + 576 = 62525
2021400 + 441 = 84129

How to Use

  1. Select the 2D or 3D tab to match your coordinate space.
  2. Enter Point 1's coordinates — x₁ and y₁ in 2D, plus z₁ in 3D.
  3. Enter Point 2's coordinates — x₂ and y₂ in 2D, plus z₂ in 3D.
  4. Click Calculate to see the distance, the midpoint, the formula used, and the step-by-step working.
  5. Click Reset to clear every field and start over.

Frequently Asked Questions

What formula does this calculator use?

For 2D: d = √((x₂−x₁)² + (y₂−y₁)²). For 3D: d = √((x₂−x₁)² + (y₂−y₁)² + (z₂−z₁)²). This is the Euclidean distance — the Pythagorean theorem applied to coordinate differences. The midpoint is the average of the coordinates on each axis: ((x₁+x₂)/2, (y₁+y₂)/2), with z included in 3D.

Can I use negative coordinates?

Yes, negative values are fully supported since coordinates can exist in any quadrant or octant. Squaring each difference removes the sign anyway — (−5)² and 5² both equal 25 — so the distance between (3, 7) and (15, 12) is identical to the distance between (15, 12) and (3, 7).

What is the midpoint used for?

The midpoint is commonly used in geometry, computer graphics, and mapping to find the center between two locations — for example, the meeting point halfway between two addresses or the center of a line segment in a drawing program.

How is the distance formula related to the Pythagorean theorem?

They are the same idea. If you plot two points and draw a right triangle whose legs run horizontally and vertically between them, the leg lengths are |x₂−x₁| and |y₂−y₁|, and the distance is the hypotenuse. The distance formula simply packages c = √(a² + b²) in coordinate notation, and the 3D version extends it with a third perpendicular leg.

What units is the distance in?

Whatever units your coordinates use. If the coordinates are in meters, the distance is in meters; if they are pixel positions on a canvas, the distance is in pixels. The calculator itself is unit-agnostic — it applies the same formula regardless, so convert your coordinates to a common unit before entering them.

Does this work offline?

Yes, all calculations are performed locally in your browser with no server communication. Once the page has loaded, you can disconnect from the internet and keep calculating.