Manhattan Distance Calculator

Add absolute coordinate differences to get the grid distance between two points.

Math and PercentUpdated 2026-11-192 min read
Manhattan Distance Calculator
Enter 1 to 6 coordinates separated by commas, for example 1, 2.
Use the same number of coordinates as point p.
Manhattan distance
...
Absolute coordinate gaps...
Straight line distance...
Number of dimensions...

What it does

Manhattan distance measures separation along a grid. Instead of drawing a straight line between two points, you add how far apart they are in each coordinate direction. The name comes from a city whose streets form a rectangular grid, where a taxi cannot cut diagonally through buildings.

This tool accepts points with one to six coordinates. Enter each point as comma separated numbers. Both points must have the same number of coordinates, and the result uses the same arbitrary unit as the inputs.

The default example uses the points (1, 2) and (7, 5). The horizontal gap is 6 and the vertical gap is 3, so the grid distance is 9. The straight line distance is the square root of 45, about 6.7082, which is always smaller or equal.

The absolute value matters. If a coordinate decreases from one point to the other, its contribution is still positive, because a taxi driving west covers just as much ground as one driving east.

This metric appears in city planning, image comparison, regression methods that penalize absolute error, and anywhere movement is constrained to axis aligned directions.

How to use

  1. Type the coordinates of point p separated by commas.
  2. Type the same number of coordinates for point q.
  3. Read the Manhattan distance as the main result.
  4. Check the individual absolute gaps in the components row.
  5. Compare with the straight line distance to see how much the grid adds.
  6. Try points that share a coordinate to see both distances coincide.

Formula

d(p,q) = sum over i of |p_i - q_i|
p_i, q_i
The i-th coordinates of the two points.
|p_i - q_i|
The absolute gap along that coordinate axis.
d(p,q)
The sum of all absolute gaps, also called the L1 distance.

For two dimensional points the formula is the horizontal gap plus the vertical gap. With Euclidean distance the gaps are squared, added and square rooted instead. The two distances are equal only when the points share at least one coordinate. The metric satisfies nonnegativity, symmetry and the triangle inequality.

Worked example

Example: from (1, 2) to (7, 5)

The page opens with p = (1, 2) and q = (7, 5).

  1. Take the horizontal gap: the absolute value of 1 minus 7 is 6.
  2. Take the vertical gap: the absolute value of 2 minus 5 is 3.
  3. Add the two gaps: 6 plus 3 is 9.
  4. The tool reports a Manhattan distance of 9 with components 6 and 3.
  5. For comparison, the straight line distance is the square root of 36 plus 9, about 6.7082.
  6. The grid distance is larger because the taxi must follow the axes.

Reference table

Manhattan and straight line distances for sample points
Point pPoint qAbsolute gapsManhattanEuclidean
(1, 2)(7, 5)6, 396.7082
(0, 0)(3, 4)3, 475
(2, 2)(2, 9)0, 777
(1, 2, 3)(4, 6, 8)3, 4, 5127.0711

Limits

  • Accepts 1 to 6 coordinates per point.
  • Coordinates must be numbers between minus 1,000,000 and 1,000,000.
  • Both points must have the same dimension.
  • The result uses the same length unit as the inputs.

Common mistakes

  • Squaring the coordinate gaps and taking a square root.
  • Adding signed differences so that opposite directions cancel.
  • Using different numbers of coordinates for the two points.
  • Assuming the grid distance can be smaller than the straight line distance.
  • Treating the result as a travel time without knowing speed or traffic.

Try it yourself

Quick checks. Answers sit tucked under each question.

Manhattan distance from (0, 0) to (3, 4)?

7. The absolute gaps are 3 and 4, while the straight line distance is 5.

Distance from (2, 2) to (2, 9)?

7. The points share an x coordinate, so the Manhattan and Euclidean distances are both 7.

Distance from (1, 2, 3) to (4, 6, 8)?

12, from gaps of 3, 4 and 5.

Questions

What is Manhattan distance?

The sum of absolute coordinate differences, as if travel is limited to a rectangular grid.

Why is it called taxicab distance?

A taxi in a gridded city must travel along streets rather than straight across blocks.

Is it the same as Euclidean distance?

No. Euclidean distance squares and square roots the gaps, and it is never larger than the Manhattan distance.

When are the two distances equal?

When the points share a coordinate, so only one axis contributes to the gap.

What does L1 mean?

It is the name of the norm formed by summing absolute values of components.

Does the unit matter?

No. Any consistent length unit works and the result uses that unit.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.