The calculators below can be used to find the distance between two points on a 2D plane or in 3D space. They can also be used to find the distance between two pairs of latitude and longitude coordinates (the great-circle or air distance).
Find the distance between two points on a 2D coordinate plane.
Find the distance between two points in 3D coordinate space.
Find the shortest distance (great-circle / air distance) between two points on the Earth's surface.
The distance calculator on this page solves three distinct kinds of distance problems. The first finds the straight-line distance between two points on a flat 2D coordinate plane. The second extends that into 3D space, adding a Z coordinate. The third finds the great-circle distance — the shortest path across the curved surface of the Earth — between two points given as latitude and longitude, reported in both kilometers and miles. Together they cover the everyday geometry-class problem, the engineering and graphics problem, and the real-world "how far apart are these two cities?" problem.
Distance is one of the most fundamental measurements there is, but the right formula depends entirely on the space you are working in. A ruler laid across a map, a diagonal through a room, and a flight path between continents are all "distances," yet each is computed differently. This calculator picks the correct method for each situation and shows the working, so you can both get the answer and understand where it comes from.
On a flat plane, the distance between two points is found with the distance formula, which is really just the Pythagorean theorem in disguise:
d = √[ (x₂ − x₁)² + (y₂ − y₁)² ]
The idea is elegant. The horizontal gap between the points (x₂ − x₁) and the vertical gap (y₂ − y₁) form the two legs of a right triangle, and the straight-line distance between the points is the hypotenuse. Squaring each leg, adding them, and taking the square root gives the length of that hypotenuse — exactly the Pythagorean theorem a² + b² = c², rearranged to solve for c.
For example, from (1, 1) to (4, 5): the horizontal gap is 3, the vertical gap is 4, so the distance is √(3² + 4²) = √(9 + 16) = √25 = 5. This is the famous 3-4-5 right triangle. Because squaring removes any negative sign, the order of the points does not matter — the distance from A to B always equals the distance from B to A.
The 2D calculator also reports the slope of the line connecting the points, the angle that line makes with the horizontal, and the equation of the line in slope-intercept form (y = mx + b). The slope m is the rise over the run, Δy / Δx; the angle is arctan(Δy / Δx); and the intercept b is found by substituting one of the points back into the equation. When the two points share the same x value the line is vertical, its slope is undefined, and only the distance is reported.
The distance formula generalizes naturally to three dimensions. With a third axis (z), the formula simply gains a third squared term:
d = √[ (x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)² ]
The reasoning is the same — it is the Pythagorean theorem applied twice. First you find the diagonal across the base (the x-y plane), then you use that diagonal and the height difference (z) as the legs of a second right triangle whose hypotenuse is the true 3D distance. For the points (1, 1, 1) and (2, 2, 2), each coordinate differs by 1, so the distance is √(1 + 1 + 1) = √3 ≈ 1.732.
Three-dimensional distance shows up constantly in the real world: the length of a cable running diagonally through a building, the separation between two aircraft at different altitudes, the distance between atoms in a molecule, collision detection in video games and physics engines, and the gap between two stars given their coordinates. Any time position has depth as well as width and height, the 3D formula is the tool.
Measuring the distance between two places on Earth is a fundamentally different problem, because the Earth is not flat. You cannot draw a straight line through the planet; the meaningful distance is the great-circle distance, the shortest path along the curved surface. This is also called the air distance or as-the-crow-flies distance, and it is close to the route a long-haul aircraft actually flies.
A great circle is any circle drawn on a sphere whose center coincides with the center of the sphere — the equator is one, and so is any line of longitude paired with its opposite. The shortest path between any two surface points always lies along the great circle that connects them. This is why flight paths on a flat map look curved: a straight line on the globe becomes a curve when the globe is flattened onto a map.
The classic textbook method for great-circle distance is the haversine formula, which treats the Earth as a perfect sphere. It is simple and accurate to within about half a percent. However, the Earth is not a perfect sphere — it bulges slightly at the equator and is flattened at the poles, forming an oblate spheroid. The equatorial radius is about 6,378 km while the polar radius is about 6,357 km, a difference of roughly 21 km. For the most accurate results, this calculator models the Earth as that ellipsoid and computes the geodesic distance across it, which is why a degree of longitude at the equator comes out slightly longer than a degree of latitude.
Latitude and longitude can be written in two common formats, and the calculator accepts both through its two tabs.
Decimal degrees (DD) express a coordinate as a single number, such as 38.8976. This is the format used by most digital maps, GPS devices, and databases. Latitudes north of the equator are positive and southern ones negative; longitudes east of the prime meridian are positive and western ones negative. Washington, D.C., for instance, sits at roughly 38.8976, −77.0366.
Degrees, minutes, seconds (DMS) is the traditional navigational format, dividing each degree into 60 minutes and each minute into 60 seconds, with a hemisphere letter (N/S for latitude, E/W for longitude). The same D.C. coordinate becomes 38° 53′ 51.36″ N, 77° 2′ 11.76″ W. To convert DMS to decimal degrees, divide the minutes by 60 and the seconds by 3,600 and add them to the degrees: 38 + 53/60 + 51.36/3600 = 38.8976. A south or west value is then made negative. The calculator does this conversion for you automatically.
The 2D and 3D calculators report the distance to high precision along with a full walk-through of the calculation, so you can follow each step from the raw coordinate differences to the final square root. The 2D calculator adds the slope, angle, and line equation as a bonus.
The latitude/longitude calculator reports the great-circle distance in both kilometers and miles, converting between them using the standard factor of 1 mile = 1.609344 km. The value it returns is the surface distance between the two points — not the driving distance, which follows roads and is always longer, and not the distance through the Earth, which would be a straight chord beneath the surface.
It is worth being clear about what "distance" means here, because the word is used loosely in everyday speech. All three calculators return the straight-line (or great-circle) distance — the shortest possible path between the two points. This is sometimes called displacement in physics, where it also carries a direction.
This is different from the route distance you would actually travel. A car driving between two cities follows roads that curve, detour, and rarely take the shortest path, so the odometer reading is always greater than the great-circle distance. A hiker climbing over a hill covers more ground than the flat map distance suggests. When you need travel distance along a specific path, a straight-line calculator gives you the theoretical minimum — a useful lower bound and a good sanity check, but not the real-world trip length.
Both the 2D and 3D formulas rest on one of the oldest results in mathematics: the Pythagorean theorem, which states that in a right triangle, the square of the hypotenuse equals the sum of the squares of the other two sides. The distance formula is nothing more than this theorem solved for the hypotenuse, with the two legs being the differences in each coordinate. Recognizing this connection makes the formulas easy to remember and easy to extend: a fourth dimension would simply add a fourth squared term under the root, and the same pattern continues into any number of dimensions.
This is also why distances are always positive. Squaring each coordinate difference discards its sign before the terms are added, so it never matters which point you label "first." The distance from point A to point B is identical to the distance from B to A — a property mathematicians call symmetry, and one of the defining features of any true distance measure.
The 2D and 3D calculators are exact — they return the true Euclidean distance limited only by the precision of the numbers you enter. The latitude/longitude calculator is highly accurate because it models the Earth as an ellipsoid rather than a sphere, but a few caveats apply. It computes distance at sea level and does not account for elevation, so the true over-terrain distance between two mountain points will be slightly longer. It also assumes the coordinates you enter are correct; a small error in a coordinate, especially in longitude near the equator, can shift the result by a surprising amount. And, as noted, it gives the direct great-circle distance, not the distance along any road, flight corridor, or shipping lane.
On a 2D plane, the distance between (x₁, y₁) and (x₂, y₂) is d = √[(x₂ − x₁)² + (y₂ − y₁)²]. It is a direct application of the Pythagorean theorem, with the coordinate differences forming the two legs of a right triangle and the distance being the hypotenuse.
Add a third squared term for the z-axis: d = √[(x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²]. The formula extends the Pythagorean theorem into three dimensions.
It is the shortest distance between two points measured along the surface of a sphere (or, more precisely, an ellipsoid like the Earth). Also called air distance or as-the-crow-flies distance, it is close to the path a long-haul aircraft flies and is always shorter than the road distance.
Great-circle distance is the straight surface path between two points. Roads curve, detour around obstacles, and follow terrain, so driving distance is always longer — often 20–40% longer — than the great-circle distance.
Divide the minutes by 60 and the seconds by 3,600, then add both to the whole degrees: decimal = degrees + minutes/60 + seconds/3600. Make the result negative for south latitudes and west longitudes. Use the DMS tab and the calculator does this automatically.
Yes. Rather than treating the Earth as a perfect sphere, it models it as an oblate spheroid (flattened at the poles) and computes the geodesic distance across that ellipsoid, which is more accurate than the simple haversine formula.
This Distance Calculator is provided for educational and general informational purposes. The 2D and 3D results are exact Euclidean distances; the latitude/longitude result is a great-circle (air) distance computed on an ellipsoidal model of the Earth and does not account for elevation or travel routes. For navigation, surveying, aviation, or other critical applications, verify distances with authoritative tools.