Cuboid space diagonal calculator
Find the longest straight line inside a box, from one corner to the opposite one: a box of 2 by 3 by 6 has a space diagonal of exactly 7. Use it to check whether a rod, brace or antenna fits in a crate. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Length
- 3
- Width
- 4
- Height
- 5
- Space diagonal
- 7.0710678119
The space diagonal of a cuboid is the straight-line segment that joins two opposite vertices through the interior of a rectangular box, not along a face or an edge. For edges length l, width w and height h, two applications of Pythagoras produce a single closed form: the space diagonal is the square root of l squared plus w squared plus h squared. Students meet this identity in solid geometry, SAT and A-level packs, and first-year engineering statics; makers, packers and CAD users need the same number when a diagonal brace, antenna, rod or clear span must fit inside a rectangular crate or enclosure that is not a perfect cube.
What the cuboid space diagonal is and why d equals the square root of l squared plus w squared plus h squared
A cuboid—also called a rectangular prism or rectangular box—has twelve edges that form three pairwise equal groups, six rectangular faces and eight vertices. From any vertex three edges leave at mutual right angles; face diagonals stay on faces; one space diagonal reaches the opposite corner through the interior. Place a cuboid with one corner at the origin and edges along the coordinate axes of lengths l, w and h.
The opposite corner sits at the point with coordinates l, w and h. The Euclidean distance from the origin to that point is the square root of l squared plus w squared plus h squared. The same result appears if you first find a face diagonal of length square root of l squared plus w squared on the base, then treat that face diagonal and the vertical edge h as legs of a right triangle whose hypotenuse is the space diagonal.
When l equals w equals h the formula collapses to the familiar cube case a times square root of three, but everyday crates, rooms and shipping boxes rarely have three equal edges. Search intent clusters around cuboid space diagonal calculator, rectangular box body diagonal, space diagonal of a rectangular prism formula, and d equals square root of l squared plus w squared plus h squared.
What you can do with it
Homework and solid-geometry drills
Students and tutors verify the body diagonal d = √(l²+w²+h²) for many rectangular boxes, including zero edges and rejection when any dimension is negative.
LMS and contest auto-grading
Mark cuboid space-diagonal items with a deterministic oracle that fails negative dimensions and never invents volume or surface metrics.
Packing, CAD clearance and crate scripts
Compute the longest internal span of a rectangular enclosure before choosing a brace, antenna, nested part or shipping insert without a full CAD kernel.
FAQ
What formula does the calculator use?
d = √(l²+w²+h²). When all three edges are equal the result matches a·√3 for a cube.
Does this tool also return volume or surface area?
No. This capability is focused on the space diagonal from three edges only. Use a general rectangular-prism calculator if you need volume, surface area or face diagonals in one call.
How do I know if a long object fits in my box?
Compare it with the space diagonal, the longest straight span inside the box. A box of 2 by 3 by 6 holds a rod of up to exactly 7 laid from one corner to the opposite one.
Can one of the dimensions be zero?
Yes. With one edge at zero the box is flat, and the diagonal is simply the diagonal of the rectangle formed by the other two edges, worked out with the same formula.
What happens if a dimension is negative?
It is rejected before any calculation, because a box cannot have a negative length, width or height. You get a clear message instead of a diagonal that only looks right.
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/cuboid-diagonal \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"length":3,"width":4,"height":5}'const res = await fetch("https://api.kit.forhosting.com/geom/cuboid-diagonal", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"length": 3,
"width": 4,
"height": 5
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/geom/cuboid-diagonal",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"length": 3,
"width": 4,
"height": 5
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/geom/cuboid-diagonal", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"length":3,"width":4,"height":5}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"length":3,"width":4,"height":5}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/geom/cuboid-diagonal", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"length": 3,
"width": 4,
"height": 5
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "geom.cuboid_diagonal",
"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
This cuboid space diagonal calculator accepts three non-negative finite dimensions, returns the echoed edges, the space diagonal, a short formula string and a method tag as structured JSON. Any negative dimension fails with invalid_input before arithmetic runs.
What the cuboid space diagonal is and why d equals the square root of l squared plus w squared plus h squared
Delivering length, width, height, space_diagonal, formula and method as JSON makes the result easy to paste into notes, assert in continuous integration or feed into a lesson platform without reimplementing three-dimensional Pythagoras in every language you teach or deploy.
Input contract, validation, response shape and error behaviour
Zero is allowed on any edge and yields a space diagonal equal to the Euclidean norm of the remaining edges, which covers degenerate flat or vanishing boxes useful in property-based tests. Length two, width three, height six yields exactly seven. Length one, width one, height one recovers the cube space diagonal square root of three. POST a JSON body with the required fields length, width and height, each a finite number greater than or equal to zero. Values may arrive as JSON numbers or as numeric strings; missing fields, empty strings, non-finite values such as NaN and non-numeric text fail with invalid_input naming the field. On success the body echoes the three edges rounded for stable goldens, the space_diagonal as the square root of the sum of squares with the same stable rounding, the formula string d equals square root of l squared plus w squared plus h squared, and method set to cuboid_diagonal. Classic example: length three, width four, height five yields space_diagonal equal to the square root of fifty, approximately seven point zero seven one. Pair the response with your own unit labels if edges are in meters or inches; this endpoint is unit-agnostic and does not convert systems of measure. It does not return face diagonals, volume or surface area—those belong to broader rectangular-prism tools—so the contract stays focused on the long-tail query for the cuboid space diagonal alone.
Where a cuboid space-diagonal API earns its keep, pricing and limits
Classrooms and tutoring platforms use a cuboid space diagonal calculator so learners can check square root of l squared plus w squared plus h squared for arbitrary rectangular boxes without calculator-mode mistakes on nested radicals. Exam generators and LMS auto-graders need a deterministic oracle that rejects negative dimensions instead of silently returning a signed length that a buggy grader might accept. Failed validation does not consume balance. Extremely large edges above the engine ceiling are rejected to avoid non-finite floating results; ordinary homework and design values stay well inside the safe range. Engineering notebooks, packing scripts and fabrication pipelines often need the longest internal clearance of a rectangular crate, room, enclosure or printed part; calling a tiny parse API avoids pulling a full solid-modeling kernel for three multiplies, two adds and one square root. Keep requests small, pin the rounded space_diagonal in tests, and you get reproducible diagonals for homework, CAD pre-checks and edge workers without standing up symbolic geometry infrastructure of your own. Prefer this focused endpoint when search intent or your integration only needs the body diagonal; use a general rectangular-prism calculator when volume and surface area must ship in the same response.
Technical questions
How do I compute the space diagonal of a cuboid from length, width and height?
Send a JSON body with length, width and height set to finite non-negative numbers. The API returns space_diagonal = √(length²+width²+height²), plus formula and method fields.
What happens if a dimension is negative?
The task fails with invalid_input. A cuboid edge cannot be negative, so the request is rejected and not billed.
What does the cuboid space diagonal calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.