Manhattan Distance Calculator - Taxicab L1 City Block Steps

Use this manhattan distance calculator to find the L1 taxicab distance between two points on a grid, plus the formula, step math, and absolute differences.

Updated: June 16, 2026 • Free Tool

Manhattan Distance Calculator

x-coordinate of the first point on the 2D plane.

y-coordinate of the first point on the 2D plane.

x-coordinate of the second point on the 2D plane.

y-coordinate of the second point on the 2D plane.

Results

Manhattan distance (d)
0units
|dx| = |x₁ − x₂| 0units
|dy| = |y₁ − y₂| 0units
Max step (Chebyshev bound) 0units

What Is a Manhattan Distance Calculator?

A manhattan distance calculator finds the L1 taxicab or city block distance between two points on a 2D coordinate plane. It is the everyday analytic-geometry tool for the question, "how many city blocks do you have to walk from (x1, y1) to (x2, y2) when you can only move along the axes?" Type the four coordinates and the page shows the L1 distance, the absolute horizontal and vertical step counts, the larger of those two steps, and the step-by-step math, so you can check your homework and trust the answer.

  • City navigation and walking time: Estimate how many blocks you actually walk between two cross streets in a grid city like New York or Chicago, where you cannot cut diagonally through a building.
  • L1 regression and LASSO in machine learning: Compute the L1 norm between two feature vectors as part of a sparse regression or k-nearest-neighbor step where the residual is measured in absolute units.
  • Grid and chess-board step counts: L1 is the count of one-square orthogonal moves along ranks and files. A standard rook covers the full horizontal or vertical distance in a single move, so the L1 sum equals the minimum rook-move count only when each move is restricted to a single square.
  • Grid-based path planning: Calculate a baseline path length for tile maps, sprite layouts, or grid-based level editors where movement is constrained to one axis at a time.

Manhattan distance is also called the taxicab distance, the city block distance, the snake distance, the rectilinear distance, and the L1 distance. For 3D coordinates or for the straight-line Euclidean distance, pair this page with the dedicated peer calculators below.

Manhattan distance is a true metric: non-negative, zero exactly when the two points coincide, symmetric, and triangle-inequality compliant. The triangle in question is a square or diamond in 2D rather than a regular Euclidean triangle.

If you would rather see the straight-line Euclidean distance for the same two points, the 2D Distance Calculator page runs the sqrt-of-squares formula on the same x1, y1, x2, y2 inputs.

How the Manhattan Distance Calculator Works

The page implements the standard L1 taxicab formula in 2D. It takes the two coordinate inputs, builds the absolute horizontal and vertical differences, and adds them.

d = |x1 - x2| + |y1 - y2|
  • x1, y1: Coordinates of the first point on the 2D plane.
  • x2, y2: Coordinates of the second point on the 2D plane.
  • |x1 − x2|: Absolute horizontal step count between the two points.
  • |y1 − y2|: Absolute vertical step count between the two points.
  • d = |dx| + |dy|: The Manhattan (L1) distance, which is always non-negative.

The formula does not care which point you call first, because the absolute value is the same in both directions. A pair (1, 1) and (5, 4) gives the same Manhattan distance as (5, 4) and (1, 1).

Worked example: walking from 1st and 1st to 5th and 4th

Point 1: (1, 1). Point 2: (5, 4).

d = |1 − 5| + |1 − 4| = 4 + 3 = 7.

d = 7 city blocks.

Walking four blocks east and three blocks north (in either order) covers 7 city blocks total, with no diagonal shortcut through the buildings.

According to Wikipedia - Taxicab geometry, the taxicab or Manhattan distance between two points in a real coordinate space is the sum of the absolute values of the differences of their Cartesian coordinates, also called the L1 distance or rectilinear distance.

When the points have a z coordinate and the L1 or L2 magnitude has to include the third axis, the 3D Distance Calculator page extends the same coordinate inputs to (x, y, z) form.

Key Concepts Behind the Manhattan Distance

Four ideas explain why the L1 metric is what it is and what the result really means on the plane.

L1 norm

The Manhattan distance is the L1 norm of the difference vector between two points. In 2D that means the sum of the absolute coordinate differences, and the same pattern extends to 3D, 4D, and any N-dimensional space by adding one more |d| term per axis.

City block / taxicab geometry

Picture a grid city like Manhattan. You cannot cut diagonally through a building, so every trip from point A to point B is the sum of horizontal blocks plus vertical blocks. The Manhattan distance counts those blocks, which is why the alternative names city block, taxicab, and snake distance all stick.

Unit sphere is a square

In Euclidean geometry the unit circle is a round curve. In taxicab geometry the unit circle is a square whose vertices sit on the coordinate axes. The boundary has four line segments and the analog of pi is exactly 4.

Triangle inequality and bounds

Manhattan distance is always greater than or equal to the Euclidean distance between the same two points. It is also bounded above by 2 times the Chebyshev (L∞) distance between the same two points, which means the Chebyshev distance is at least half of the Manhattan distance and gives a quick lower bound for L1.

These four ideas are the building blocks of L1 geometry. Once you know what the metric is, what shape the unit ball has, and how the bounds compare to Euclidean distance, you can read papers that use L1 norms without being thrown off by the notation.

Many real-world problems in machine learning use the L1 norm because it is robust to outliers and promotes sparse solutions. The Chebyshev bound in particular is useful when you want a quick lower bound for an L1 distance.

If you want to see the L2 (Euclidean) magnitude of a single vector that starts at the origin, the Vector Magnitude Calculator page runs the sqrt-of-squares formula on one vector instead of two points.

How to Use This Manhattan Distance Calculator

Five short steps cover every common case, from a clean city block example to negative coordinates and decimal inputs.

  1. 1 Enter x₁ and y₁: Type the coordinates of the first point. The default is (1, 1), the corner of 1st Avenue and 1st Street.
  2. 2 Enter x₂ and y₂: Type the coordinates of the second point. The default is (5, 4), so the example starts at the 7-block walking distance from the first point.
  3. 3 Read the Manhattan distance: The primary output is the L1 distance, updated as you type. It is the same number whether you swap the two points or not, because the absolute value wipes out the sign.
  4. 4 Check the supporting values: Look at |dx|, |dy|, and the max step to confirm the arithmetic. The max step is also the Chebyshev distance, the lower bound for the L2 (Euclidean) distance.
  5. 5 Reset or compare with Euclidean: Click Reset to return to the example. To see the straight-line distance between the same two points for comparison, open the 2D distance calculator in a new tab.

Try the points (-2, -3) and (3, 9). The calculator gives |dx| = 5, |dy| = 12, Manhattan distance = 17, and the max step = 12. The straight-line Euclidean distance for the same pair is 13, which sits between 12 and 17 exactly as the bounds predict.

Once you have |dx|, |dy|, and the L1 sum, the Right Triangle Calculator page can fill in the missing leg, hypotenuse, or angle of the right triangle those values describe.

Benefits of Using This Manhattan Distance Calculator

These benefits matter most when you are working a problem by hand and need a quick, trustworthy check.

  • Skip the sign and absolute-value mistakes: Manual Manhattan distance problems are easy to get wrong on the absolute-value step. The calculator handles the absolute-value and the sum so you can focus on setting up the problem.
  • See the full step-by-step math: The page shows |dx|, |dy|, the L1 sum, and the max step. That makes it a good way to check your own work, not just a way to get a number.
  • Compare with the Euclidean and Chebyshev distances at a glance: You often need to compare the L1 distance with the L2 (Euclidean) distance for the same pair of points. The max step and the Chebyshev bound give you that comparison without leaving the page.
  • Handle any sign of coordinate: Negative coordinates, decimal coordinates, and points far from the origin all use the same formula. The page does not require you to pre-process the numbers.
  • Connect to the rest of analytic geometry: If your next step is to draw the right triangle, plot the points on a grid, or convert the result to a different unit, the page links out to the relevant peer calculator in the same category.

The page is most useful as a check, not as a replacement for understanding the metric. Use it to confirm a homework answer, sanity-check a walking estimate, or pre-validate a feature vector before you hand it to a longer L1-regression script.

If you want to plot the two points and the L1 path between them on a labeled grid, the Coordinate Plane Calculator page draws the picture that the |dx| and |dy| numbers describe.

Factors That Affect the Manhattan Distance Result

The formula is the same in every case, but a few factors change how the result should be read or compared with other metrics.

Order of the two points

Swapping (x1, y1) and (x2, y2) flips the sign of both dx and dy, but absolute value removes the sign. The distance, the absolute steps, and the max step are all unchanged.

Coordinate scale and unit

The result is in the same unit as the coordinates. If x and y are in city blocks, d is in city blocks. If you need meters, feet, or pixels, use the Distance Converter on the result.

Numerical precision of the inputs

Very small rounding in the coordinates can shift the L1 distance. Enter coordinates with as much precision as the original problem gives.

Coaxial edge case (dx = 0 or dy = 0)

When the two points share an x or y axis, only one absolute difference is non-zero. The Manhattan distance then equals the Euclidean distance because there is no diagonal to cut.

Rotation of the coordinate system

Unlike the Euclidean distance, the Manhattan distance depends on the orientation of the coordinate axes. A 45-degree rotation of the plane changes d because the new axes are no longer aligned with the original.

  • This page is the planar, 2D case only. For 3D points (x, y, z), the formula needs an extra z term; the 3D distance calculator handles that directly.
  • The calculator assumes a flat 2D plane. It does not account for distance on the surface of a sphere (great-circle distance) or through a 3D volume with obstacles.
  • Manhattan distance is the L1 norm, not the L2 norm. If your problem needs the straight-line Euclidean distance, use the 2D distance calculator instead.

According to Wolfram MathWorld, the taxicab metric is the L1 distance on R^n defined as the sum of the absolute coordinate differences, and the corresponding unit sphere in two dimensions is a square aligned with the coordinate axes.

If the answer is in generic units and you want city blocks, meters, feet, or pixels, the Distance Converter page changes the unit of the L1 sum without changing the math.

manhattan distance calculator showing a city grid with two points and the L1 path between them
manhattan distance calculator showing a city grid with two points and the L1 path between them

Frequently Asked Questions

Q: What is the formula for the Manhattan distance between two points?

A: The formula is d = |x1 - x2| + |y1 - y2|. Subtract the x-coordinates, take the absolute value, do the same with the y-coordinates, and add the two absolute differences. That sum is the Manhattan (L1) distance between the two points.

Q: How do I calculate the Manhattan distance between two points?

A: Enter the coordinates of the first point as x1 and y1, then the coordinates of the second point as x2 and y2. The calculator returns the L1 distance, the absolute horizontal and vertical step counts, the larger of those two steps, and the L1 sum in one pass.

Q: What is the difference between Manhattan and Euclidean distance?

A: Euclidean distance is the straight-line length between two points. Manhattan distance is the sum of the absolute coordinate differences, as if you could only walk along the axes. For any pair of points, Manhattan distance is greater than or equal to the Euclidean distance.

Q: Can the Manhattan distance be smaller than the Euclidean distance?

A: No. For the same two points, the Manhattan distance is always greater than or equal to the Euclidean distance. The two values are equal only when the two points share an x or y axis, so the straight-line path runs along a coordinate axis.

Q: What happens if both points are the same in the Manhattan distance calculator?

A: If x1 equals x2 and y1 equals y2, both absolute differences are zero, the L1 sum is zero, and the Manhattan distance is exactly 0. The max step is also 0, which matches the rule that the distance is zero exactly when the two points coincide.

Q: Where is the Manhattan distance used in real life?

A: It is used to count city blocks walked on a grid, to count one-square orthogonal steps on a chess-like board (a king restricted to four cardinal directions, or a rook limited to one square per move), to compute L1 residuals in regression and LASSO, and to define norms in compressed sensing, image processing, and several machine-learning loss functions.