The space diagonal of a box with length l, width w and height h is d = √l2 + w2 + h2. It is the longest straight line that fits inside the box, running from one corner to the opposite corner. This 3D Pythagorean theorem calculator finds it, or works backward from the diagonal to a missing dimension.
How to use the box diagonal calculator
- Measure the box. You need its length, width and height in the same unit. Which dimension you call length or width does not change the diagonal.
- Type any three of the four values. Leave the diagonal empty to find it. To find a missing dimension instead, enter the diagonal and the other two dimensions and leave that box empty.
- Read the results. You get the answer in exact form when there is one, the decimal, the working, the three face diagonals, the angle between the space diagonal and the floor, the volume and the surface area.
The calculator remembers which three boxes you typed in most recently, so you can switch from "find the diagonal" to "find the height" just by typing in a different box.
The 3D Pythagorean theorem in two steps
The formula looks new, but it is the ordinary Pythagorean theorem used twice. First cross the floor of the box, then climb to the far top corner. Both moves are right triangles.
In symbols: the floor diagonal satisfies e2 = l2 + w2. The height stands straight up from the floor, so it meets e at a right angle, and d2 = e2 + h2. Substituting the first equation into the second removes e:
d2 = l2 + w2 + h2 d = √l2 + w2 + h2To find a missing dimension, rearrange: h = √d2 − l2 − w2. The diagonal must be the longest of the four lengths, and d2 must be larger than the other two squares added together, otherwise no such box exists. The 3D Pythagorean theorem lesson explains the geometry in more detail, and the same formula measures the distance between two points in space in the distance calculator.
Worked examples
Example 1: the diagonal of a shipping box
A box measures 12 in by 9 in by 8 in. How long is its space diagonal?
d= √122 + 92 + 82 = √144 + 81 + 64= √289 = 17The space diagonal is exactly 17 in. This is the example loaded in the calculator.
Example 2: the longest pole that fits in a room
A room is 12 ft long, 10 ft wide and 8 ft high. What is the longest straight pole that fits inside?
d= √122 + 102 + 82 = √144 + 100 + 64= √308 = 2√77 ≈ 17.55About 17.55 ft, reaching from a floor corner to the opposite ceiling corner. On the floor alone the longest line is only √244 ≈ 15.62 ft.
Example 3: find a missing height
A box has a space diagonal of 13 cm, a length of 4 cm and a width of 3 cm. How tall is it?
h= √132 − 42 − 32 = √169 − 16 − 9= √144 = 12The box is 12 cm tall. Enter 4, 3 and 13 and leave the height empty to check.
Example 4: decimal measurements
A storage crate is 1.2 m by 0.8 m by 0.5 m.
d = √1.44 + 0.64 + 0.25 = √2.33 ≈ 1.5264The diagonal is about 1.53 m, rounded to the nearest centimeter.
Will it fit? Using the space diagonal
The most common real question behind this calculation is whether something long and thin fits inside a box, a car trunk or a room. Three rules cover it:
- If the object is shorter than the longest side, it fits lying flat. No theorem needed.
- If it is shorter than a face diagonal, it fits lying flat across that face. The calculator lists all three face diagonals, √l2 + w2, √l2 + h2 and √w2 + h2.
- If it is shorter than the space diagonal, it fits only when tilted from a bottom corner to the opposite top corner. If it is longer than the space diagonal, it does not fit at all.
Example 5: does a 20-inch umbrella fit?
The box is 16 in by 12 in by 6 in. Its longest face diagonal is √162 + 122 = √400 = 20 in, exactly the length of the umbrella, so lying flat it would be a squeeze with no room for the handle. The space diagonal is
d = √162 + 122 + 62 = √436 = 2√109 ≈ 20.88Tilted corner to corner, the umbrella fits with almost an inch to spare.
More fitting and packing questions, with full solutions, are on the word problems page.
Watch outThe space diagonal assumes a thin object and an empty, perfectly rectangular space. Real objects have thickness and real trunks have curved walls, so leave a margin.
Cubes: the √2 and √3 shortcut
When all three dimensions are equal, the box is a cube with side s, and the formulas collapse into two memorable results. A face diagonal is √s2 + s2 = s√2, the same as the diagonal of a square and the hypotenuse of a 45-45-90 triangle. The space diagonal is √s2 + s2 + s2 = s√3.
For a cube with 5 cm edges the face diagonal is 5√2 ≈ 7.07 cm and the space diagonal is 5√3 ≈ 8.66 cm. The space diagonal makes an angle of about 35.26° with the floor of any cube, whatever its size.
Boxes with whole-number diagonals
Most boxes have an irrational diagonal. The ones that come out whole are called Pythagorean quadruples, the 3D cousins of Pythagorean triples. These are all the primitive ones (no common factor) with a diagonal up to 17:
| l | w | h | d | Check |
|---|---|---|---|---|
| 1 | 2 | 2 | 3 | 1 + 4 + 4 = 9 |
| 2 | 3 | 6 | 7 | 4 + 9 + 36 = 49 |
| 1 | 4 | 8 | 9 | 1 + 16 + 64 = 81 |
| 4 | 4 | 7 | 9 | 16 + 16 + 49 = 81 |
| 2 | 6 | 9 | 11 | 4 + 36 + 81 = 121 |
| 6 | 6 | 7 | 11 | 36 + 36 + 49 = 121 |
| 3 | 4 | 12 | 13 | 9 + 16 + 144 = 169 |
| 2 | 5 | 14 | 15 | 4 + 25 + 196 = 225 |
| 2 | 10 | 11 | 15 | 4 + 100 + 121 = 225 |
| 1 | 12 | 12 | 17 | 1 + 144 + 144 = 289 |
| 8 | 9 | 12 | 17 | 64 + 81 + 144 = 289 |
Multiply any row by a whole number to get another box with a whole diagonal. The 12 × 9 × 8 box in the calculator is the 8-9-12-17 row in a different order. Teachers can use these to write 3D problems with clean answers; ready-made ones are on the 3D Pythagorean theorem worksheet.
Common mistakes
- Stopping at the floor diagonal. √l2 + w2 is only the first step. The space diagonal also includes h2.
- Adding the lengths instead of their squares. For the 12 × 9 × 8 box, 12 + 9 + 8 = 29, but the diagonal is 17.
- Mixing units. A box that is 2 ft by 18 in by 10 in must be converted to one unit first: 24 in by 18 in by 10 in.
- Subtracting in the wrong order when solving for a side. Always start from d2, the largest square. More on this on the common mistakes page.
Frequently asked questions
What is the 3D Pythagorean theorem?
It says that the diagonal d of a rectangular box satisfies d2 = l2 + w2 + h2. It comes from applying a2 + b2 = c2 twice, once across the floor and once from the floor diagonal up to the opposite top corner.
What is the difference between a face diagonal and a space diagonal?
A face diagonal crosses one flat face of the box, so it uses two dimensions, such as √l2 + w2. A space diagonal goes through the inside of the box from one corner to the opposite corner and uses all three. A box has 12 face diagonals (2 on each of 6 faces) and 4 space diagonals, and the 4 space diagonals all have the same length.
How do you find the diagonal of a cube?
Multiply the side length by √3. A cube with 10 cm edges has a space diagonal of 10√3 ≈ 17.32 cm. Its face diagonals are 10√2 ≈ 14.14 cm.
Can I find the height of a box from its diagonal?
Yes, if you also know the length and width. Use h = √d2 − l2 − w2: enter the diagonal, the length and the width and leave the height empty. The result only exists when d2 is bigger than l2 + w2.
Does the formula work for shapes that are not boxes?
It works for any two points in space, which is why it doubles as the 3D distance formula. For a cylinder, the longest straight line inside runs across the circular base and up, so use the diameter and the height: √dbase2 + h2. For slanted shapes such as pyramids, split the problem into right triangles one step at a time.
Keep exploring
- LearnThe Pythagorean Theorem in 3DThe Pythagorean theorem in 3D: find the space diagonal of a box or cube, d = √(l² + w² + h²), with an animated two-step proof, fit problems and 3D distance.
- CalculatorsDistance Formula CalculatorFree distance formula calculator for 2D and 3D points. Get the distance with steps, the exact radical answer, the midpoint, the slope and a graph.
- TriplesPythagorean QuadruplesPythagorean quadruples are whole-number boxes with a whole-number space diagonal: full list up to d = 41, how to make them, Euler bricks and the perfect cuboid.
- Practice3D Pythagorean Theorem WorksheetPrintable 3D Pythagorean theorem worksheet: 12 problems on boxes, cubes, cones and square pyramids, each with a 3D drawing, plus a fully worked answer key.
- CalculatorsRectangle Diagonal CalculatorFree rectangle diagonal calculator. Enter any two of length, width and diagonal to get the third, plus the diagonal angle, square mode and full working.
- LearnDe Gua's TheoremDe Gua's theorem says the squared area of the slanted face of a right-corner tetrahedron equals the sum of the other three. Proofs, examples and history.