Distance Calculator (2D)
Find the distance between any two points using their x and y coordinates.
What this calculator does
This calculator takes the x and y coordinates of two points and returns the straight-line distance between them, in whatever units your coordinates use. It computes the Euclidean distance, which is the length of the shortest possible path between the two points. At the defaults, the points (0, 0) and (3, 4) sit exactly 5 units apart.
How the distance formula works
The formula needs two subtractions and one square root. The horizontal difference dx = x₂ − x₁ tells you how far the second point sits to the right of the first, and the vertical difference dy = y₂ − y₁ tells you how far up it sits. Squaring each difference strips the sign, adding the squares combines the two directions, and the square root converts that sum back into a plain length. The result carries whatever unit your coordinates carry: if x and y are in feet, the distance is in feet; if they are pixels, the distance is in pixels.
The connection to Pythagoras
The two differences are the legs of a right triangle, and the straight-line distance is its hypotenuse. With dx = 3 and dy = 4 you get the classic 3-4-5 triangle, which is why the default answer comes out so clean. Most point pairs do not land on a perfect triple, so expect irrational answers such as √2 ≈ 1.414 or √13 ≈ 3.606, and round them to the precision you actually need.
Order does not matter
Squaring removes any sign from the differences, so 5 measured from (0, 0) to (3, 4) is the same as 5 measured from (3, 4) back to (0, 0). Even flipping the direction of one subtraction changes nothing, because a squared negative equals a squared positive. The one thing you cannot do is pair the wrong coordinates, such as subtracting a y value from an x value, which describes points that are not yours.
Worked example: from (0, 0) to (3, 4)
Step 1 — find the differences. dx = 3 − 0 = 3 and dy = 4 − 0 = 4. These are the two legs of the right triangle formed by the two points and the origin.
Step 2 — square both and add. 3² = 9 and 4² = 16, so the sum of squares is 9 + 16 = 25.
Step 3 — take the square root. √25 = 5, so the points are exactly 5 units apart. The arithmetic scales linearly: the pair (0, 0) to (6, 8) doubles both differences and doubles the distance to 10, while (0, 0) to (1.5, 2) halves them and halves the distance to 2.5.
Common point pairs and their distances
| Point pair | dx, dy | Distance |
|---|---|---|
| (0, 0) to (3, 4) | 3, 4 | 5 |
| (0, 0) to (6, 8) | 6, 8 | 10 |
| (0, 0) to (5, 12) | 5, 12 | 13 |
| (0, 0) to (1, 1) | 1, 1 | √2 ≈ 1.414 |
| (2, 3) to (2, 11) | 0, 8 | 8 |
| (0, 0) to (10, 0) | 10, 0 | 10 |
Pairs whose squared differences add to a perfect square give whole-number answers; everything else leaves an irrational root that you round to suit the job. Same-x or same-y pairs collapse to a single leg, so their distance is just the absolute difference — 8 units straight up in the (2, 3) to (2, 11) row, with dx = 0 contributing nothing to the sum.
What changes the result
- Scale: doubling both coordinate differences doubles the distance, because every term under the root is multiplied by 4 and √4 = 2.
- Axis-only movement: if one difference is 0, the distance equals the other difference alone, so (2, 3) to (2, 11) is simply 8.
- Units: the answer inherits the unit of the inputs. Coordinates in inches give a distance in inches, and no unit conversion happens inside the formula.
- Sign and order: negative coordinates and swapped points leave the distance unchanged, since only squared differences enter the calculation.
- Rounding early: rounding dx or dy before squaring throws the answer off. A difference rounded from 4.5 down to 4 removes 0.5² = 0.25 from the sum of squares.
Mistakes that produce a wrong distance
The most common error is crossing axes: subtracting an x value from a y value, or entering a point as (y, x). The formula still returns a number, so nothing looks broken, but the answer describes a different pair of points. The second mistake is skipping the squares and computing √(dx + dy); for dx = 3 and dy = 4 that wrong route gives √7 ≈ 2.65 instead of 5. The third is mixing units between the two points, such as one pair in feet and the other in meters, which silently produces a meaningless number.
Rounding deserves a note too. If your inputs are accurate to one decimal place, report the distance to one or two decimals at most; quoting √2 as 1.4142135 implies precision your inputs never had. In construction or material work, round the quantity up rather than the distance down, because a short distance translates directly into a short cut.
Where this calculation shows up
- Coordinate geometry and algebra homework, where distance-between-points questions appear on standardized tests from middle school through the SAT.
- Screen layout and game development, where the pixel distance between two elements drives hit detection, collision radius and spacing checks.
- Mapping, where the straight-line, as-the-crow-flies distance between two locations comes from their grid coordinates before anyone considers road routing.
- Construction layout, where crews recreate the 3-4-5 triple from this formula to confirm a corner is square.
The formula is also the building block behind everyday distance claims. A park described as a half mile away is a straight-line figure; the walking route can easily run 0.7–0.9 miles because paths bend around blocks. Knowing which kind of distance a number represents keeps estimates honest, and it explains why two apps can report different values for the same two points.
Distance in the plane versus other dimensions
In three dimensions you add a third squared term, giving d = √(dx² + dy² + dz²); the logic is identical, just one axis longer. The vector magnitude calculator runs the same arithmetic on a vector measured from the origin, and the Pythagorean theorem calculator works from triangle side lengths instead of coordinates. If you know the hypotenuse and one leg but not the coordinates, the theorem calculator is the faster tool; if you have all four coordinate values, this page does the job directly.
Frequently asked questions
How do I find the distance between two points?
Subtract to get dx = x₂ − x₁ and dy = y₂ − y₁, square both, add the squares, and take the square root. For (0, 0) to (3, 4): √(9 + 16) = √25 = 5.
What is the distance between (0, 0) and (3, 4)?
Exactly 5 units. The differences are dx = 3 and dy = 4, which form the classic 3-4-5 Pythagorean triple, so the square root comes out whole.
Does the order of the points matter?
No. Because the differences are squared, the distance is the same in both directions. Swapping the two points changes the sign of dx and dy but not the final answer.
How is this related to the Pythagorean theorem?
The distance is the hypotenuse of a right triangle whose legs are the x and y differences. The formula is the Pythagorean theorem written with coordinate differences in place of side lengths.
What if the two points share an x or y coordinate?
The distance is just the absolute difference on the other axis. The points (2, 3) and (2, 11) differ only in y, so they are 8 units apart.
Can the distance be negative?
No. The square root of a sum of squares is always zero or positive. A distance of 0 means the two points are identical.
What units is the answer in?
Whatever your coordinates use. If x and y are in feet, the distance is in feet; if they are pixels, the answer is pixels. No conversion happens inside the formula.
Why does my map app show a different distance?
This formula gives the straight-line, as-the-crow-flies distance. Road and walking routes bend around streets and terrain, so they run longer — a 0.5 mile straight-line walk often measures 0.7–0.9 miles along streets.
How do I extend the formula to 3D points?
Add the z difference as a third squared term: d = √(dx² + dy² + dz²). The arithmetic and the rounding rules are exactly the same.
How precisely should I round the result?
Match your inputs. One decimal place in the coordinates supports one or two decimals in the answer, so √2 is fairly reported as 1.41 rather than 1.4142135.
Method and sources
- Euclidean distance formula in two dimensions.