Distance Formula (2D) Calculator
The distance formula answers one of the most common questions in coordinate geometry: how far apart are two points on a plane? This calculator computes that straight-line distance for you. Enter the coordinates of the first point as x1 and y1 and the second as x2 and y2, and the tool finds the horizontal difference and the vertical difference, squares each, adds them, and takes the square root to give the distance between the points. The method is the Pythagorean theorem written in coordinates: the two points are the ends of the hypotenuse of a right triangle whose legs are the horizontal and vertical gaps, so the distance is the square root of the sum of the squared legs. It works for any consistent units, whether meters, grid squares or pixels, and the result carries those same units. The order of the points does not matter because the differences are squared, so distance from A to B equals distance from B to A and is always zero or positive. Use it to check geometry homework, measure separations on a map grid, or verify a graphics calculation. Every figure is computed deterministically from the formula shown below, with a worked example that reconciles exactly to the calculator's defaults.
The distance between two points is d = sqrt((x2 - x1)^2 + (y2 - y1)^2). From point (1, 2) to point (4, 6), the differences are 3 and 4, giving a distance of 5.00.
Distance formula
d = sqrt( (x2 - x1)^2 + (y2 - y1)^2 )
(x1, y1) = coordinates of the first point
(x2, y2) = coordinates of the second point
dx = x2 - x1, dy = y2 - y1
Find the horizontal gap (dx) and vertical gap (dy), square each, add them, and take the square root. The result is the straight-line distance between the two points.
Worked example
Find the distance from the point (1, 2) to the point (4, 6).
- dx = 4 - 1 = 3
- dy = 6 - 2 = 4
- dx squared + dy squared = 9 + 16 = 25
- d = square root of 25 = 5.00
The distance is 5.00. These are the calculator's default inputs, so the result above matches the widget exactly. This is the classic 3-4-5 right triangle.
Distance for sample point pairs
Straight-line distance between a few point pairs.
| Point 1 | Point 2 | Distance |
|---|---|---|
| (0, 0) | (3, 4) | 5.00 |
| (1, 2) | (4, 6) | 5.00 |
| (0, 0) | (5, 12) | 13.00 |
| (2, 1) | (2, 7) | 6.00 |
The distance formula is the Pythagorean theorem expressed in coordinates.
Distance formula calculator: frequently asked questions
What is the distance formula?
The 2D distance formula gives the straight-line distance between two points in a plane. It is d = the square root of (x2 minus x1) squared plus (y2 minus y1) squared. You take the horizontal difference and the vertical difference, square each, add them, and take the square root. It comes directly from the Pythagorean theorem applied to the right triangle formed by the two points.
How is the distance formula related to the Pythagorean theorem?
The two points form the ends of the hypotenuse of a right triangle whose legs are the horizontal distance (x2 minus x1) and the vertical distance (y2 minus y1). The Pythagorean theorem says the hypotenuse squared equals the sum of the squares of the legs, so the distance is the square root of that sum. The distance formula is the Pythagorean theorem written in coordinates.
Does the order of the points matter?
No. Because each difference is squared, swapping the points or the sign of a difference gives the same result. Distance from point A to point B equals distance from B to A. You can enter the points in either order and the calculator returns the same positive distance.
Can the distance be negative?
No. Distance is always zero or positive. The squares inside the formula remove any negative signs, and a square root of a non-negative number is non-negative. If both points are identical, the distance is zero. Otherwise it is a positive value representing the straight-line separation.
What units does the result use?
The result is in the same units as the coordinates you enter. If x and y are in meters, the distance is in meters; if they are grid units or pixels, the distance is in those units. The formula does not assume any particular unit, so it works for any consistent coordinate system.
Official sources
- Mathematical functions and reference formulas: US National Institute of Standards and Technology (NIST). As at 25 June 2026.
Reviewed by the CalculatorHub team, edited by James Graham, 25 June 2026. See our methodology. This is general information, not financial, tax, legal or investment advice.