Skip to content

Distance formula calculator

Enter two points to find their straight-line distance in a 2D coordinate plane.

Coordinates of the two points

Your data stays in this browser.

Enter finite x and y coordinates. Negative numbers and decimals are supported.

Point A
Point AA (1, 2)
Point B
Point BB (4, 6)

Distance result

Your result will appear here

Enter both points, then select Calculate.

How to use the distance formula calculator

Enter the two endpoints

Label the first point A(x₁, y₁) and the second point B(x₂, y₂). Type each coordinate in its own field, keeping the x- and y-values from the same point together. Negative coordinates and decimal coordinates are valid. Use a decimal point rather than a thousands separator or unit text.

Select Calculate after all four fields are complete. The result panel reports the horizontal change Δx, vertical change Δy, and the distance. The diagram uses the same entered points and rescales them to fit; it is a coordinate sketch, not a map or a measurement in metres, miles, or another physical unit.

Why the distance formula works

The segment from A to B is the hypotenuse of a right triangle. Its horizontal leg has length |x₂ − x₁| and its vertical leg has length |y₂ − y₁|. Applying the Pythagorean theorem gives d = √((x₂ − x₁)² + (y₂ − y₁)²). Squaring makes the sign of each difference irrelevant, so reversing A and B gives the same distance.

The calculator preserves the signed differences because they show direction from A to B, but distance itself is nonnegative. The displayed calculation substitutes your values before taking the square root, making it easier to check copied coordinates or a handwritten solution.

Read and use the result

The main distance is rounded to at most two ordinary decimal places for readability. Internal arithmetic keeps JavaScript number precision until display. Very small nonzero or very large supported values use compact scientific notation so a meaningful value is not shown as zero.

Use Copy result to copy a short text summary containing the points, coordinate differences, and distance. Editing any input immediately clears the previous result and disables copying, preventing an old answer from being mistaken for a calculation based on new coordinates.

Worked examples

A(1, 2) and B(4, 6)

Δx = 4 − 1 = 3 and Δy = 6 − 2 = 4. Therefore d = √(3² + 4²) = √25 = 5.

A(−2.5, 3) and B(1.5, −1)

Δx = 4 and Δy = −4. The distance is √(4² + (−4)²) = √32 ≈ 5.66. Negative coordinates do not make the distance negative.

The same point twice

A(3, −2) and B(3, −2) produce Δx = 0 and Δy = 0, so the distance is 0. This is a valid distance result.

Uses, limits, and output

Appropriate uses

This focused tool is useful for coordinate-geometry homework, checking the length of a plotted segment, comparing points in a chart, and verifying values before drawing a line. It calculates ordinary Euclidean distance in a flat two-dimensional coordinate plane.

What this calculator does not measure

Coordinates are unitless unless you assign a common unit to both axes. The tool does not calculate driving routes, GPS or great-circle distance, elevation, three-dimensional distance, distance from a point to a line, or the equation of the connecting line. Use a mapping or specialist geometry tool for those different tasks.

All inputs and results must stay within the documented finite numeric range. If an extreme subtraction or square-root result cannot be represented safely, the calculator shows an error instead of Infinity or a misleading rounded answer.

Frequently asked questions

Can the coordinates be negative or decimal values?

Yes. Enter signed real numbers such as −3 or 2.75 using a decimal point.

Does the order of the points change the distance?

No. Reversing A and B changes the signs of Δx and Δy, but their squares and the final distance stay the same.

Why is the answer sometimes not a whole number?

The square root may be irrational. The display gives a readable decimal approximation while the substituted square-root expression shows how it was obtained.

Is zero distance an error?

No. Identical points have a valid distance of zero.

Can I use latitude and longitude?

Not for accurate geographic distance. Latitude and longitude lie on Earth, so use a geodesic or mapping calculator instead.