Distance between two points
Type two points on a plane and get the straight-line distance between them: from (0, 0) to (3, 4) is exactly 5, with the horizontal and vertical differences shown so you can follow the Pythagorean step. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- X1
- 0
- Y1
- 0
- X2
- 3
- Y2
- 4
- Distance
- 5
- Dx
- 3
- Dy
- 4
Given two points on the Cartesian plane, the straight-line separation is the Euclidean distance: the square root of the sum of squared differences in x and in y. This calculator accepts x1, y1, x2, and y2 as finite numbers, validates every coordinate, and returns the non-negative distance together with the normalized points, the deltas dx and dy, and a method tag of euclidean.
How the Euclidean formula measures planar distance
Label the first point as (x1, y1) and the second as (x2, y2). The classical Pythagorean identity on the plane states that the length of the segment joining them is the square root of (x2 minus x1) squared plus (y2 minus y1) squared. Classic classroom checks include the right-triangle legs of three and four units, which produce distance five, and the unit diagonal from (0, 0) to (1, 1), which produces the square root of two.
Because the formula uses only subtraction, multiplication, addition, and a single square root, it is deterministic, O(1), and free of trigonometric libraries or iterative solvers.
Where planar point distance shows up in real work
Secondary-school and college analytic geometry courses constantly ask students to find the distance between two plotted points; a trusted calculator with a strict numeric check speeds homework grading and removes spreadsheet mistakes where someone forgets to square both deltas or takes absolute values instead of a true hypotenuse. Game, graphics, and CAD tutorials often store sprites, nodes, and control points as pairs of screen or world coordinates; the distance answer feeds collision radii, snap thresholds, and path-length estimates without building a full computational-geometry stack.
Drafting and simple GIS workflows that already project points into a local Cartesian plane need the planar length of a two-corner segment before staking or reporting—having a shared numeric oracle keeps field notes and office scripts aligned on the same Euclidean path. If you later need Manhattan distance, 3D Euclidean length, or great-circle distance on a globe, treat those as separate search intents rather than overloading this two-point planar landing.
What you can do with it
Homework and exam checks
Compute the straight-line distance between two plotted points and reject non-numeric coordinates with a clear error.
Game and CAD helpers
Turn two 2D coordinate pairs into a Euclidean length for snap radii, collision proxies, and path segments.
FAQ
What formula does this calculator use?
The Euclidean formula: distance = √((x2 − x1)² + (y2 − y1)²). The response includes method: "euclidean".
What happens if a coordinate is not a number?
Missing fields, empty strings, non-numeric text, NaN, and Infinity are all rejected.
Does point order matter?
No. Distance is symmetric: swapping the two points yields the same non-negative length (dx and dy flip sign).
Are coordinates 2D only?
Yes. This tool expects planar Cartesian x and y values. It does not compute 3D distance or geographic great-circle length.
What does it cost?
The browser tool is free and runs locally.
Related tools
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/geom/distance-2d \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"x1":0,"y1":0,"x2":3,"y2":4}'const res = await fetch("https://api.kit.forhosting.com/geom/distance-2d", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"x1": 0,
"y1": 0,
"x2": 3,
"y2": 4
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geom/distance-2d",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"x1": 0,
"y1": 0,
"x2": 3,
"y2": 4
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geom/distance-2d", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"x1":0,"y1":0,"x2":3,"y2":4}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"x1":0,"y1":0,"x2":3,"y2":4}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geom/distance-2d", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"x1": 0,
"y1": 0,
"x2": 3,
"y2": 4
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geom.distance_2d",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Missing fields, empty strings, non-numeric text, NaN, and Infinity are rejected with a clear invalid_input error instead of a silent NaN that looks like a successful solve. No network calls, no random sampling, and no floating-point surprises beyond ordinary IEEE-754 arithmetic on the four numbers you provide.
How the Euclidean formula measures planar distance
That expression is always non-negative, is zero exactly when the two points coincide, and is symmetric under swapping the two endpoints. Large coordinates can still overflow IEEE-754 double range when squared; when the intermediate sum is non-finite the request fails with a clear overflow message instead of returning Infinity in JSON. That closed path matches how survey courses, analytic geometry textbooks, and computational geometry primers present the distance-between-two-points problem, and it keeps automated graders and pipelines aligned with hand computation without unit conversion or map projections mixed into the same call.
What you send and what you get back
Provide four required finite numbers: x1 and y1 for the first point, x2 and y2 for the second. After parsing, the service computes dx equals x2 minus x1 and dy equals y2 minus y1, takes the square root of dx squared plus dy squared, and checks that the distance is a finite number. Example checks: zero, zero, three, four yields distance five; zero, zero, one, one yields the square root of two rounded; a non-numeric y2 fails naming that field. Wire the free browser tool for quick sanity checks, then call the identical contract from scripts when you need bulk evaluation of planar distances without reimplementing the numeric gate in every language. Short aliases ax, ay, bx, by and x_a through y_b are accepted so form labels can stay compact without diverging handlers. Missing fields, empty strings, non-numeric text, NaN, and Infinity are rejected with invalid_input and are not charged. On success the JSON response returns distance rounded for stable serialization, echoes the four normalized coordinates, includes dx and dy, and sets method to the string euclidean so logs and teaching UIs can document the metric. API pricing is the published base of $0.002 per successful item.
Where planar point distance shows up in real work
Because this capability is a pure parse engine, failed validation does not consume balance and successful runs stay at $0.002 per item.
Integration use cases
Local-plane survey segments
From two projected endpoints, recover planar segment length before reporting or staking a line.