Distance Calculator
Find the distance between two points in 2D or 3D, or between two latitude and longitude coordinates, with the formula worked out step by step.
Decimal degrees (40.7128, −74.0060) or degrees, minutes and seconds (40°42′46″N). South and West are negative.
The straight line from A to B: the hypotenuse of a right triangle with legs 3 and 4.
Plot of the two points
Dashed legs show Δx and Δy. Both axes use the same scale.
Your calculation
The same steps the calculator runs, with your numbers.
Points along the segment from A to B
Each point is A + t × (B − A). The highlighted row is the midpoint.
Distances use the units you enter.
What Is the Distance Between Two Points?
The distance between two points is the length of the shortest path that joins them. On a flat graph that path is a straight line segment, and its length comes from the distance formula. In space the same idea extends to three coordinates. On the Earth the shortest path follows the curved surface, so it is measured along a great circle or, more precisely, along a geodesic on the ellipsoid.
This distance calculator covers all three cases. Use 2D points for coordinate geometry homework, graphs and floor plans. Use 3D points for physics, CAD models, game development and any problem with height. Use latitude and longitude for GPS coordinates, maps and the distance between two cities as the crow flies.
Every result comes with the steps, so you can check the answer by hand or copy the working into an assignment.
How to Use the Distance Calculator
- Pick the distance type. 2D points take x and y, 3D points add z, and latitude and longitude take two GPS coordinates.
- Enter Point A and Point B. Negative numbers and decimals are accepted. For coordinates, type decimal degrees such as 51.5074 and −0.1278, or degrees, minutes and seconds such as 51°30′27″N. A letter S or W makes the value negative.
- Choose a unit. In 2D and 3D the unit only labels the answer. For coordinates, pick kilometers, miles or nautical miles, and the other two appear beside the result.
For 2D points you get the distance with its exact radical form, a plot, Δx, Δy, slope, angle, the line equation, the Manhattan distance and points along the segment including the midpoint. For 3D points you get how d² splits across the axes, the horizontal distance and the elevation angle. For coordinates you get the ellipsoid distance, the spherical haversine distance, the initial and final bearing, the midpoint, the central angle and travel times at typical speeds.
Distance Formula (2D)
The distance formula is the Pythagorean theorem applied to the right triangle whose legs are the horizontal change Δx and the vertical change Δy.
With negative coordinates, keep the signs when subtracting. For A(−3, 5) and B(4, −1): Δx = 4 − (−3) = 7 and Δy = −1 − 5 = −6, so d = √(49 + 36) = √85 ≈ 9.2195. Since 85 = 5 × 17 has no square factor, √85 is already the exact answer.
3D Distance Formula
In three dimensions, add the squared change in z. The result is the space diagonal of a box whose edges are Δx, Δy and Δz.
The horizontal distance ignores z: √(3² + 4²) = 5. The elevation angle above the xy plane is atan(12 ÷ 5) ≈ 67.38°. These are the two tiles that 3D mode adds.
Distance Between Latitude and Longitude Coordinates
Latitude φ and longitude λ are angles, so the flat distance formula does not apply. The haversine formula gives the great circle distance on a sphere of radius R. This calculator uses R = 6,371.0088 km, the mean radius (2a + b) ÷ 3 of the WGS84 ellipsoid.
The Earth is not a perfect sphere. Its equatorial radius is 6,378,137 m and its flattening is 1/298.257223563 under WGS84, the datum GPS uses. Vincenty's inverse method solves the distance on that ellipsoid by iteration and gives 5,585.2 km (3,470.5 mi) for the same route, 15.0 km more than the sphere. That ellipsoid figure is the main result in the calculator.
Distances Between Major Cities
Straight line distances on the WGS84 ellipsoid between commonly used city center coordinates, calculated with the same code as the calculator and rounded to whole units.
| Route | km | Miles | Nautical miles |
|---|---|---|---|
| London to Paris | 344 | 214 | 186 |
| Delhi to Mumbai | 1,145 | 711 | 618 |
| New York to Los Angeles | 3,944 | 2,451 | 2,130 |
| London to Dubai | 5,480 | 3,405 | 2,959 |
| New York to London | 5,585 | 3,471 | 3,016 |
| Sydney to Singapore | 6,301 | 3,915 | 3,402 |
| Los Angeles to Tokyo | 8,838 | 5,492 | 4,772 |
| New York to Tokyo | 10,876 | 6,758 | 5,872 |
| London to Sydney | 16,989 | 10,557 | 9,173 |
Coordinates used: London 51.5074, −0.1278; Paris 48.8566, 2.3522; New York 40.7128, −74.0060; Los Angeles 34.0522, −118.2437; Tokyo 35.6762, 139.6503; Sydney −33.8688, 151.2093; Singapore 1.3521, 103.8198; Dubai 25.2048, 55.2708; Delhi 28.6139, 77.2090; Mumbai 19.0760, 72.8777. Airport to airport distances differ because airports sit away from city centers.
Length of One Degree
One degree of latitude stays near 111 km. One degree of longitude shrinks toward the poles by the cosine of the latitude. Values on the WGS84 ellipsoid:
| Latitude | 1° latitude | 1° longitude |
|---|---|---|
| 0° | 110.574 km | 111.319 km |
| 15° | 110.649 km | 107.550 km |
| 30° | 110.852 km | 96.486 km |
| 45° | 111.132 km | 78.847 km |
| 60° | 111.412 km | 55.800 km |
| 75° | 111.618 km | 28.902 km |
Use this table for quick estimates: 0.01° of latitude is about 1.1 km, so four decimal places locate a point to roughly 11 m.
Kilometers, Miles and Nautical Miles
The international mile and the nautical mile are both defined exactly in meters, so conversions carry no rounding error of their own.
Nautical miles are used in aviation and shipping because one nautical mile is close to one minute of latitude: on a sphere of radius 6,371.0088 km, one minute of arc is 1,853.3 m.
Euclidean, Manhattan and Great Circle Distance
The calculator reports more than one kind of distance because different problems measure travel differently.
- Euclidean distance is the straight line length from the distance formula. From (1, 2) to (4, 6) it is 5.
- Manhattan distance, also called taxicab distance, adds the absolute differences: |3| + |4| = 7. It fits city grids, warehouse aisles and some machine learning tasks where movement follows the axes.
- Great circle distance is the shortest path on a sphere. A flat map makes long routes look curved, because the straight line on the globe does not match the straight line on the map.
- Geodesic distance is the shortest path on the ellipsoid. It is the most accurate surface distance for GPS coordinates.
The same inputs also give the midpoint, ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2), which is (2.5, 4) for the first example, and the slope, Δy ÷ Δx = 4/3.
Common Mistakes When Calculating Distance
- Dropping a negative sign. 4 − (−3) is 7, not 1. Squaring removes the sign of the difference, but only after you subtract correctly.
- Adding before squaring. √(3² + 4²) is 5, while 3 + 4 = 7 is the Manhattan distance, not the straight line.
- Swapping latitude and longitude. Latitude comes first and ranges from −90° to 90°. Entering −74.0060 as a latitude puts New York in Antarctica.
- Forgetting West and South. Western longitudes and southern latitudes are negative. Typing 74.0060 instead of −74.0060 moves the point to Central Asia.
- Reading minutes as decimals. 40°30′ is 40.5°, not 40.30°.
- Mixing units. All coordinates must use the same unit. Convert first, then calculate.
Related Calculations
The Pythagorean Theorem Calculator solves for any side of a right triangle, which is the idea behind the distance formula. The Slope Calculator finds the slope, angle and equation of the line through two points.
Use the Right Triangle Calculator or the Triangle Calculator when you know three points and need angles or area. The Conversion Calculator converts the result to other length units.
Frequently Asked Questions
How do you calculate the distance between two points?
Subtract the coordinates to get the change in x and the change in y, square both, add them and take the square root: d = √((x₂ − x₁)² + (y₂ − y₁)²). For A(1, 2) and B(4, 6), Δx = 3 and Δy = 4, so d = √(9 + 16) = √25 = 5. The formula is the Pythagorean theorem applied to the right triangle whose legs are Δx and Δy. The order of the points does not matter, because squaring removes the sign. For points given as latitude and longitude, use the haversine formula or an ellipsoid method instead.
What is the distance formula in 3D?
In three dimensions you add the squared change in z: d = √((x₂ − x₁)² + (y₂ − y₁)² + (z₂ − z₁)²). For A(1, 2, 3) and B(4, 6, 15), the differences are 3, 4 and 12, so d = √(9 + 16 + 144) = √169 = 13. Geometrically, d is the space diagonal of a box with edges 3, 4 and 12. The horizontal part alone, √(3² + 4²) = 5, is the distance you would measure on a floor plan, and the full 13 includes the climb in z.
How do you calculate the distance between two latitude and longitude points?
Convert both coordinates to radians and apply the haversine formula: a = sin²(Δφ/2) + cos φ₁ × cos φ₂ × sin²(Δλ/2), c = 2 × atan2(√a, √(1 − a)) and d = R × c, with R = 6,371.0088 km, the mean radius of the WGS84 ellipsoid. For New York (40.7128, −74.0060) to London (51.5074, −0.1278) this gives 5,570.2 km on a sphere. Because the Earth is slightly flattened, this calculator also runs Vincenty's ellipsoid method, which gives 5,585.2 km, or 3,470.5 miles.
How accurate is the haversine formula?
The haversine formula is exact for a perfect sphere, but the Earth is an ellipsoid whose equatorial radius is about 21 km longer than its polar radius. On the routes in the city table on this page, the spherical result differs from the WGS84 ellipsoid distance by 0.03 to 0.31 percent, for example 5,570 km against 5,585 km from New York to London. That is close enough for travel estimates and most apps. Surveying and geodesy use ellipsoid methods such as Vincenty's or Karney's, which is why this calculator shows the ellipsoid distance as the main result.
Is straight line distance the same as driving distance?
No. Straight line distance, often called distance as the crow flies, is the shortest path over the Earth's surface between two coordinates. Roads follow terrain, rivers and property lines, so driving distance is almost always longer, and flight paths bend around restricted airspace and follow the winds. Use the straight line figure to compare locations, estimate radio or delivery range, or check whether a place lies within a given radius. For trip planning, use a routing service that follows the actual road network.
How many miles is one degree of latitude?
One degree of latitude is about 69 miles, or 111 km, everywhere on Earth. On the WGS84 ellipsoid it ranges from 110.574 km (68.71 miles) at the equator to 111.618 km (69.36 miles) at 75° latitude, because the Earth is flatter near the poles. One degree of longitude shrinks with latitude: 111.319 km at the equator, 78.847 km at 45° and 28.902 km at 75°. One nautical mile is exactly 1,852 meters, close to the length of one minute of latitude.
Sources & References
- OpenStax. College Algebra 2e, 2.1 The Rectangular Coordinate Systems and Graphs (distance formula and midpoint formula). openstax.org
- OpenStax. Calculus Volume 3, 2.2 Vectors in Three Dimensions (distance between two points in space). openstax.org
- National Geospatial Intelligence Agency. World Geodetic System 1984, standard NGA.STND.0036_1.0.0_WGS84 (defining parameters a and f). nga.mil
- Vincenty, T. Direct and Inverse Solutions of Geodesics on the Ellipsoid with Application of Nested Equations, Survey Review 23(176), 1975. Copy hosted by NOAA National Geodetic Survey. ngs.noaa.gov
- Karney, C. F. F. Algorithms for Geodesics, Journal of Geodesy 87, 43–55, 2013 (arXiv 1109.4448). arxiv.org
- NIST. Guide to the SI, Appendix B.8: Factors for Units Listed Alphabetically (mile = 1,609.344 m, nautical mile = 1,852 m). nist.gov
Results are for educational and planning purposes, not for navigation or surveying. Every number on this page was recomputed with the same code the calculator uses. Methodology reviewed: 2026.