ForHosting KIT · Math

Coordinate distance calculator

Enter two points and get the straight-line distance between them: from (1, 2) to (4, 6) it is exactly 5, because the sides of the right triangle are 3 and 4. Made for points on a flat plane. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
X1
1
Y1
2
X2
4
Y2
6
You get
Distance
5
Dx
3
Dy
4

The coordinate distance calculator answers one precise question: given two points in a plane, each described by an x and a y coordinate, how far apart are they along a straight line? It applies the Euclidean formula, the square root of the sum of the squared differences in x and in y, after validating that all four coordinates are finite numbers.

The distance is the long side of a right triangle

Picture a horizontal line through one point and a vertical line through the other: the straight path between the two points becomes the long side of a right triangle. One short side is the change in x and the other is the change in y. The Pythagorean theorem then gives the distance: square both changes, add them and take the square root. From (1, 2) to (4, 6) the changes are 3 and 4, so the distance is the square root of 3² + 4², which is 5. From (0, 0) to (1, 1) it is the square root of 2, about 1.414213562373.

Where it helps, and what to keep in mind

It is the quick check for geometry homework, the length of a segment on a floor plan or projected grid, and the proximity test behind collision radii and snap distances in games and drawing tools. The result is never negative, it is zero only when both points are the same, and swapping the points does not change it, because each difference is squared. It measures on a flat plane with no map projection or unit conversion applied, and it works in two dimensions, so points with a height need a 3D distance calculator. Text, blanks or infinite values are rejected with a clear message.

The Euclidean formula behind coordinate distance

Name the first point (x1, y1) and the second (x2, y2). The straight-line separation between them is the hypotenuse of a right triangle whose legs run parallel to the axes: one leg is the horizontal difference x2 minus x1, the other is the vertical difference y2 minus y1. The Pythagorean theorem then gives the distance as the square root of (x2 minus x1) squared plus (y2 minus y1) squared.

Classic sanity checks make the formula memorable: from (0, 0) to (3, 4) the distance is exactly 5, and from (0, 0) to (1, 1) it is the square root of 2, about 1.414213562373. Because the computation uses only subtraction, multiplication, addition, and one square root, it runs in constant time with no trigonometric tables, no iterative solvers, and no dependence on external libraries.

Homework and exam checks

Verify the straight-line distance between two plotted points and catch non-numeric coordinates with a clear error message.

Game and CAD proximity logic

Turn two x/y coordinate pairs into a Euclidean length for collision radii, snap thresholds, and path segments.

Local-plane measurements

From two points on a projected grid or floor plan, recover the planar segment length for reports and field notes.

What formula does this calculator use?

The Euclidean formula: distance = √((x2 − x1)² + (y2 − y1)²). The response includes method: "euclidean" to confirm the metric.

What happens if a coordinate is not a finite number?

Missing fields, empty strings, non-numeric text, NaN, and Infinity are all rejected before any arithmetic runs.

Does the order of the two points matter?

No. Distance is symmetric: swapping the points yields the same non-negative length, while dx and dy simply flip sign.

Does it work in 3D or on a map?

No. It expects planar Cartesian x and y coordinates only. It does not compute 3D distance or geographic great-circle distance.

What does it cost?

The browser tool is free and runs locally.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/math/coordinate-distance

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/math/coordinate-distance \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"x1":1,"y1":2,"x2":4,"y2":6}'
{
  "x1": 1,
  "y1": 2,
  "x2": 4,
  "y2": 6
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.coordinate_distance",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

The response returns the non-negative distance together with the normalized coordinates, the deltas dx and dy, and a method tag of euclidean so automated consumers can document which metric was used. Missing fields, empty strings, non-numeric text, NaN, and Infinity are rejected with a clear invalid_input error rather than a silent NaN that masquerades as a valid answer. The same pure module powers the free browser tool and the paid API, so results are byte-identical in both places. There are no network calls, no random sampling, and no hidden unit conversions: just deterministic IEEE-754 arithmetic on the four numbers you provide, at $0.002 per successful API item.

The Euclidean formula behind coordinate distance

This value is always non-negative, equals zero exactly when the two points coincide, and is unchanged if you swap the endpoints, because each difference is squared. Extremely large coordinates can still overflow double-precision range when squared; in that case the request fails with a clear overflow message instead of returning Infinity in JSON. This is the same derivation taught in analytic geometry courses and used by computational geometry texts, so results line up with hand computation and classroom graders without any projection or unit system mixed into the call.

Inputs, validation, and the shape of the result

Send four required finite numbers: x1 and y1 for the first point, x2 and y2 for the second. Once all four coordinates parse as finite numbers, the service computes dx as x2 minus x1 and dy as y2 minus y1, then takes the square root of dx squared plus dy squared. A final guard confirms the distance itself is finite. Two quick checks: inputs zero, zero, three, four yield distance five; inputs one, two, four, six yield distance five as well because the deltas are three and four. Compact aliases ax, ay, bx, by and x_a through y_b are also accepted so short form labels work without diverging code paths. Validation runs before any arithmetic: a missing field, an empty string, non-numeric text such as abc, or the special values NaN and Infinity all fail with an invalid_input error that names the offending field, and failed validation is not charged. The JSON response returns distance rounded to twelve decimal places for stable serialization across machines, echoes the four normalized coordinates, includes dx and dy so teaching interfaces can show the components, and sets method to the string euclidean for logging and documentation. API usage costs $0.002 per successful item.

Practical uses for planar coordinate distance

Coordinate distance shows up anywhere entities live on a flat grid. In software, games, graphics tools, and CAD sketches store sprites, nodes, and control points as x/y pairs; the distance answer feeds collision radii, snap-to-point thresholds, proximity triggers, and path-length estimates without pulling in a full computational-geometry library. Mapping-adjacent work that already projects points onto a local Cartesian plane, such as a small construction site or a warehouse floor plan, uses the same formula to recover segment lengths between two surveyed corners. Because the capability is a pure parse engine, there is no randomness and no clock dependence, so the same input always produces the same output in the browser and in the API. If you need Manhattan distance, 3D Euclidean length, or great-circle distance on the globe, those are different intents served by different tools; this one stays deliberately focused on the two-point planar case at $0.002 per item.

Read the full KIT documentation →