100+ free calculators, no signup | 💰 Financial ❤️ Health & Fitness 📐 Math 🔧 Other
🇺🇸 USD | About Contact

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.

Point A
Point B
Quick examples
2D distance from A(1, 2) to B(4, 6)
5unitsExact value

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

    1. Pick the distance type. 2D points take x and y, 3D points add z, and latitude and longitude take two GPS coordinates.
    2. 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.
    3. 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.

    d = √((x₂ − x₁)² + (y₂ − y₁)²) A(1, 2), B(4, 6) Δx = 4 − 1 = 3, Δy = 6 − 2 = 4 d = √(3² + 4²) = √(9 + 16) = √25 = 5

    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.

    d = √(Δx² + Δy² + Δz²) A(1, 2, 3), B(4, 6, 15) Δx = 3, Δy = 4, Δz = 12 d = √(9 + 16 + 144) = √169 = 13

    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.

    a = sin²(Δφ/2) + cos φ₁ × cos φ₂ × sin²(Δλ/2) c = 2 × atan2(√a, √(1 − a)), d = R × c New York (40.7128, −74.0060) to London (51.5074, −0.1278) φ₁ = 0.710572 rad, φ₂ = 0.898974 rad Δφ = 10.7946° = 0.188401 rad, Δλ = 73.8782° = 1.289418 rad a = 0.008848 + 0.757989 × 0.622414 × 0.361160 = 0.179236 c = 2 × atan2(0.423363, 0.905960) = 0.874309 rad d = 6,371.0088 × 0.874309 = 5,570.2 km

    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.

    ℹ️
    Vincenty's method does not converge for points that are almost exactly opposite each other on the globe. In that rare case the calculator shows the haversine result and says so. Karney's 2013 algorithm handles those points as well.

    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.

    RoutekmMilesNautical miles
    London to Paris344214186
    Delhi to Mumbai1,145711618
    New York to Los Angeles3,9442,4512,130
    London to Dubai5,4803,4052,959
    New York to London5,5853,4713,016
    Sydney to Singapore6,3013,9153,402
    Los Angeles to Tokyo8,8385,4924,772
    New York to Tokyo10,8766,7585,872
    London to Sydney16,98910,5579,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:

    Latitude1° latitude1° longitude
    0°110.574 km111.319 km
    15°110.649 km107.550 km
    30°110.852 km96.486 km
    45°111.132 km78.847 km
    60°111.412 km55.800 km
    75°111.618 km28.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.

    1 mi = 1.609344 km 1 nmi = 1.852 km 1 km = 0.621371 mi = 0.539957 nmi 1 nmi = 1.150779 mi 5,585.2 km ÷ 1.609344 = 3,470.5 mi 5,585.2 km ÷ 1.852 = 3,015.8 nmi

    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.
    ⚠️
    Straight line distance is not driving or flight distance. Routes follow roads and air corridors, so expect real trips to be longer than the result.

    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.