Distance Between Two Points Calculator

Stephanie Ben-Joseph headshot Stephanie Ben-Joseph

What is the distance between two points?

The distance between two points is the length of the straight line that connects them. In a coordinate system, each point is written as a set of numbers (coordinates). This calculator lets you enter the coordinates of two points in 2D (x, y) or 3D (x, y, z) and returns the Euclidean straight-line distance between them.

In 2D, a point has coordinates (x1, y1) or (x2, y2). In 3D, a point has coordinates (x1, y1, z1) or (x2, y2, z2). The calculator automatically switches between 2D and 3D distance based on whether you provide z-coordinates.

Distance formula

The formulas used by this calculator come directly from the Pythagorean theorem, which relates the sides of a right triangle. The straight-line distance between two points is the length of the hypotenuse of a right triangle built from the coordinate differences.

2D distance formula

For two points in the plane, (x1, y1) and (x2, y2), the Euclidean distance d between them is:

d = √[(x2 − x1)² + (y2 − y1)²]

d = ( x2 x1 ) 2 + ( y2 y1 ) 2

3D distance formula

For two points in space, (x1, y1, z1) and (x2, y2, z2), the Euclidean distance d between them is:

d = √[(x2 − x1)² + (y2 − y1)² + (z2 − z1)²]

d = ( x2 x1 ) 2 + ( y2 y1 ) 2 + ( z2 z1 ) 2

Geometric interpretation

To see where these formulas come from, imagine plotting the two points on a coordinate grid.

  • The horizontal difference between the points is Δx = x2 − x1.
  • The vertical difference is Δy = y2 − y1.

These two differences form the legs of a right triangle. The distance between the points is the hypotenuse. By the Pythagorean theorem:

d² = (Δx)² + (Δy)²

Taking the square root of both sides gives the 2D distance formula. In 3D, there is an extra dimension with difference Δz = z2 − z1. The length now satisfies:

d² = (Δx)² + (Δy)² + (Δz)²

Again taking the square root gives the 3D formula. This is an example of the Euclidean metric, which measures straight-line separation in standard Cartesian space.

How to use the calculator

  1. Enter the coordinates of the first point in the Point 1 fields.
  2. Enter the coordinates of the second point in the Point 2 fields.
  3. Click the Calculate Distance button to see the result.

2D vs 3D:

  • For a 2D distance, fill in x and y for both points and leave the z fields blank.
  • For a 3D distance, fill in x, y, and z for both points.

The calculation runs entirely in your browser. The coordinates you type are not sent to a server.

Worked examples

Example 1: 2D distance

Suppose you have two points in the plane:

  • Point 1: (x1, y1) = (1, 2)
  • Point 2: (x2, y2) = (5, 5)

Step 1: Compute the differences:

  • Δx = x2 − x1 = 5 − 1 = 4
  • Δy = y2 − y1 = 5 − 2 = 3

Step 2: Apply the 2D distance formula:

d = √[(Δx)² + (Δy)²] = √[(4)² + (3)²] = √(16 + 9) = √25 = 5

The straight-line distance between (1, 2) and (5, 5) is 5 units.

Example 2: 3D distance

Now consider two points in 3D space:

  • Point 1: (x1, y1, z1) = (2, −1, 3)
  • Point 2: (x2, y2, z2) = (6, 2, 7)

Step 1: Compute the coordinate differences:

  • Δx = 6 − 2 = 4
  • Δy = 2 − (−1) = 3
  • Δz = 7 − 3 = 4

Step 2: Apply the 3D distance formula:

d = √[(Δx)² + (Δy)² + (Δz)²] = √[(4)² + (3)² + (4)²] = √(16 + 9 + 16) = √41

Numerically, √41 ≈ 6.403. So the straight-line distance between the two 3D points is about 6.403 units.

Common uses and interpretation

Interpreting the result is straightforward: the distance tells you how far apart the two points are in a straight line, using the same units as your coordinates (meters, kilometers, inches, etc.). A larger value means the points are farther apart.

Typical uses include:

  • Geometry and algebra: solving problems that ask for the length of a segment between two coordinates.
  • Physics: computing displacement between positions in 2D or 3D.
  • Engineering and CAD: checking clearances and dimensions between features in a model.
  • Computer graphics and games: measuring distances between objects, for example for collision detection.
  • Data analysis: using Euclidean distance as a simple measure of how similar or different two data points are.

Because the formula is based on squared differences, negative coordinate values do not cause problems. Only the relative differences between the coordinates matter, and the final distance is always non‑negative.

2D vs 3D distance: comparison

The table below compares the key features of the 2D and 3D formulas used by this calculator.

Aspect 2D distance 3D distance
Point format (x1, y1) and (x2, y2) (x1, y1, z1) and (x2, y2, z2)
Formula d = √[(x2 − x1)² + (y2 − y1)²] d = √[(x2 − x1)² + (y2 − y1)² + (z2 − z1)²]
Dimensions measured Horizontal and vertical separation in a flat plane Separation in three perpendicular directions (often width, height, depth)
Typical use cases Graphs, maps of small areas, 2D diagrams, basic geometry problems 3D models, physics in space, engineering drawings, 3D games
Calculator inputs Only x and y fields filled; z fields left empty All x, y, and z fields filled for both points

Assumptions and limitations

This calculator makes several important assumptions:

  • Euclidean straight-line distance: It uses the standard Euclidean metric. The result is the length of the straight line between two points, not the length of any path that might bend or turn.
  • Cartesian coordinates: The formulas assume you are working in a Cartesian coordinate system where the x, y, and z axes are perpendicular and measured in consistent units.
  • Flat space approximation: For geographic locations on Earth, it does not account for the planet’s curvature. For long distances on the globe, you would need great‑circle or geodesic formulas instead.
  • No obstacles or networks: Real‑world travel distance along roads, corridors, or other constrained paths is usually longer than the straight‑line distance returned here.
  • Numeric precision: The computation uses standard floating‑point arithmetic in your browser. Extremely large or small values, or many decimal places, can introduce small rounding errors.

If you keep these assumptions in mind, the distance formula is a reliable and widely applicable tool for measuring how far apart two points are in both 2D and 3D settings.

Enter coordinates to compute the distance.

Embed this calculator

Copy and paste the HTML below to add the Distance Between Two Points Calculator to your website.