Distance Calculator

Calculate Euclidean and Manhattan distance between two points, plus midpoint and slope.

Point A

Point B

Euclidean Distance

5.000000

√(3² + 4²) = √(25)

Manhattan Distance7.000000
Midpoint(1.5, 2)
Slope1.333333
Δx (run)3
Δy (rise)4

How to Use the Distance Calculator

This distance calculator (also called a distance between two points calculator, coordinate distance calculator, or point distance formula calculator) returns the Euclidean straight-line distance and the Manhattan grid distance between any two points on a 2D plane. All math happens in your browser as you type, so you can test dozens of coordinate pairs in a minute.

  1. Enter Point A as (x1, y1). Defaults load to (0, 0). Negative numbers and decimals both work, so a point at (-2.5, 7) is fine.
  2. Enter Point B as (x2, y2). Defaults load to (3, 4), which gives the classic 3-4-5 right triangle with a distance of 5.
  3. Read the four result tiles. The large number is the Euclidean distance. Below it you will find the Manhattan distance, the midpoint coordinates, the slope of the line through the two points, and the Δx and Δy differences.
  4. Use the slope and midpoint for geometry homework, drafting, or any task where you need the line that passes through both points. A slope of 1.333 with a midpoint of (1.5, 2) fully describes the line segment.

This tool covers 2D coordinate geometry. For geographic distance such as miles between cities or kilometres between airports, plug latitude and longitude into the Haversine formula below. The straight-line formula here will give a wrong answer for global distances because it ignores Earth's curvature.

Distance Formulas and Worked Examples

The distance formula you need depends on the geometry of the space. Flat 2D and 3D coordinates use the Pythagorean theorem. Grid-restricted movement uses taxicab math. Points on a sphere, such as cities on Earth, use the Haversine formula. All four are below with worked numbers.

1. Euclidean distance in 2D (the classic distance formula)

d = √((x2 − x1)² + (y2 − y1)²)

Example: A = (0, 0), B = (3, 4)
d = √((3 − 0)² + (4 − 0)²)
d = √(9 + 16)
d = √25
d = 5

2. Euclidean distance in 3D

When the points have a z-coordinate (height, depth, or a third axis), extend the formula with one more squared difference.

d = √((x2 − x1)² + (y2 − y1)² + (z2 − z1)²)

Example: A = (1, 2, 3), B = (4, 6, 8)
d = √((4 − 1)² + (6 − 2)² + (8 − 3)²)
d = √(9 + 16 + 25)
d = √50
d ≈ 7.071

3. Manhattan (taxicab) distance

Manhattan distance measures the shortest path along a grid where diagonal moves are not allowed. Named after the NYC street grid, where you cannot cut through buildings.

d_M = |x2 − x1| + |y2 − y1|

Example: A = (0, 0), B = (3, 4)
d_M = |3| + |4| = 7
(3 blocks east plus 4 blocks north = 7 blocks walked)

4. Haversine formula for great-circle distance

For two points on Earth given as latitude φ and longitude λ in radians, the great-circle distance along the surface uses the Haversine formula. R is Earth's mean radius, about 6,371 km (or 3,959 miles).

Δφ = φ2 − φ1
Δλ = λ2 − λ1

a = sin²(Δφ/2) + cos(φ1) × cos(φ2) × sin²(Δλ/2)
d = 2R × asin(√a)

R ≈ 6,371 km  (or 3,959 mi)

Example: New York (40.7128°N, 74.0060°W)
         Los Angeles (34.0522°N, 118.2437°W)
d ≈ 3,944 km ≈ 2,451 miles (straight-line over the surface)

Convert degrees to radians first by multiplying by π ÷ 180. Forgetting that step is the most common Haversine bug.

5. Midpoint and slope

Midpoint M = ((x1 + x2) ÷ 2, (y1 + y2) ÷ 2)
Slope   m = (y2 − y1) ÷ (x2 − x1)

Example: A = (0, 0), B = (3, 4)
M = (1.5, 2)
m = 4 ÷ 3 ≈ 1.333

6. Time, speed, and distance

If you know two of these three quantities, the third follows from the same triangle of equations. Useful for travel math, running pace, and anything involving steady motion.

d = v × t      (distance equals speed × time)
v = d ÷ t      (speed equals distance ÷ time)
t = d ÷ v      (time equals distance ÷ speed)

Example: 240 miles at 60 mph
t = 240 ÷ 60 = 4 hours

Quick reference: 2D vs Manhattan distance

Coordinate pairs worked both ways. Notice that Euclidean distance is always less than or equal to Manhattan distance, with equality only when one of the two coordinates matches.

Point APoint BΔxΔyEuclideanManhattan
(0, 0)(3, 4)345.0007
(0, 0)(5, 0)505.0005
(1, 2)(4, 6)345.0007
(-2, -3)(2, 3)467.21110
(0, 0)(1, 1)111.4142
(10, 5)(-4, 12)-14715.65221

Picking the Right Distance: Straight-Line, Grid, or Great-Circle

Distance is not one number. How far apart two points are depends on what movement is allowed between them. A crow flying over Manhattan travels a shorter distance than a taxi covering the same two addresses, and a plane flying from New York to Los Angeles covers a different distance again than a car driving the same route. This section covers when each distance metric applies and where people usually slip up.

Which distance metric fits which problem

The calculator above reports Euclidean and Manhattan distance. In the real world, pick the one that matches how motion actually happens.

SituationUseWhy
Geometry homework, CAD, physics in a flat spaceEuclidean 2D or 3DStraight line, no obstacles
City driving in a grid (NYC, Salt Lake City, Chicago)ManhattanNo diagonal cutting through blocks
Chess king, 8-direction game movementChebyshev (max of Δx, Δy)Diagonal counts as one step
Miles between cities, flight planningHaversineEarth is a sphere, not a plane
Driving directions between citiesRoad-network distance (Google Maps, Waze)Follows real highways and roads
K-nearest-neighbour ML, recommender systemsEuclidean or cosine similarityDepends on whether magnitude matters

Why flight distance, drive distance, and great-circle distance never match

Three different numbers describe the distance between New York City and Los Angeles, and all three are correct for their own question.

MeasureDistanceWhat it describes
Great-circle (Haversine)≈ 3,944 km / 2,451 miShortest path along Earth's surface
Actual flight path≈ 4,080 km / 2,535 miJet route adjusted for wind and airspace
Driving distance (I-80/I-70 route)≈ 4,491 km / 2,790 miInterstate highways through several states

The 547 km gap between the great-circle number and the driving number is the price of needing a road. Airlines come close to the great-circle number because they can fly a curved path over the surface, but wind, traffic, and restricted airspace add a few percent. If someone asks "how many miles between cities" without specifying, great-circle is the default for flight, road-network is the default for driving.

Common traps when calculating distance

  • Latitude vs longitude order. Google Maps and most human-readable sources write coordinates as (latitude, longitude). Most programming libraries, including GeoJSON, use (longitude, latitude). Swapping them silently produces wrong distances.
  • Degrees vs radians. The Haversine formula requires radians. Feeding it raw degrees returns a number that looks plausible but is off by a factor of roughly 57. Always multiply degrees by π ÷ 180 first.
  • Nautical vs statute miles. Aviation and marine charts use nautical miles (1 nm = 1.852 km). Road signs and driving apps use statute miles (1 mi = 1.609 km). A "100 mile" flight leg is 115 statute miles.
  • Earth radius choice. Use 6,371 km (mean radius) for general-purpose distance. For survey-grade work, use the ellipsoid (Vincenty's formulae) instead of Haversine, which can be off by 0.5% at long distances.
  • Negative distance. Distance is always positive. If you are getting a negative number, you forgot the absolute value or the square root.

Quick real-world distance checks

Useful sanity numbers to keep in mind when a distance calculator returns something that seems off.

DistanceGreat-circleTypical driving
NYC to Los Angeles2,451 mi / 3,944 km2,790 mi / 4,491 km
London to Paris214 mi / 344 km288 mi / 463 km
Sydney to Melbourne443 mi / 713 km545 mi / 878 km
Tokyo to Osaka245 mi / 395 km319 mi / 514 km
Chicago to Miami1,197 mi / 1,926 km1,383 mi / 2,225 km

Road distance runs 12% to 16% longer than great-circle for most intercity routes in the lower 48 United States. If your number is more than 25% off in either direction, check your coordinates and units.

Frequently Asked Questions

The distance formula calculates the straight-line distance between two points in a coordinate plane. It is derived from the Pythagorean theorem: d = √[(x2 - x1)² + (y2 - y1)²]. The horizontal and vertical differences form the legs of a right triangle, and the distance is the hypotenuse. For (0, 0) and (3, 4), the distance is √(9+16) = 5, a classic 3-4-5 right triangle.

Related Calculators