What this calculator does
A diagonal is a straight line connecting two non-adjacent corners of a shape, and its length depends entirely on which shape is being measured: a rectangle’s diagonal crosses a flat face, while a cube has both a shorter face diagonal and a longer diagonal that cuts straight through the solid from corner to corner.
This diagonal calculator covers all three cases, rectangle, square and cube, switching between them with a single selector so the same "diagonal" question gets the right formula whichever shape it is actually being asked about.
The formula
For a rectangle, the diagonal follows Pythagoras across the two sides: d = √(length² + width²). A square is the special case where both sides match, simplifying to d = side × √2. A cube extends the same idea into three dimensions: its space diagonal, corner to opposite corner through the solid, is d = side × √3, longer than any single face diagonal.
| Term | Meaning |
|---|---|
| Diagonal | A straight line joining two corners that are not already connected by an edge. |
| Face diagonal | On a cube, the diagonal across one flat square face, equal to side × √2. |
| Space diagonal | On a cube, the diagonal running from one corner straight through the solid to the opposite corner, equal to side × √3. |
The inputs explained
| Field | What to enter |
|---|---|
| Shape | Choose whether the diagonal formula needed is for a rectangle, a square, or a cube. |
| Length (rectangle), or side length (square/cube) | The length of the rectangle, or the side length of the square or cube. |
| Width (rectangle only) | The width of the rectangle. Not used for a square or a cube, since all their sides are equal. |
When to use it
Checking a doorway, panel or screen will fit
A rectangular panel, screen or doorway opening needs its diagonal checked against a corridor or delivery gap, since a flat object can often pass through diagonally even when neither of its straight sides fits.
Squaring up a rectangular frame or foundation
A rectangular deck, foundation or garden bed is confirmed as truly square-cornered by comparing its two diagonals; if they match, the corners are genuine right angles.
Finding the longest straight measurement inside a box
Fitting a long, rigid item such as a pole or pipe inside a rectangular box or cube-shaped crate depends on the space diagonal, the longest straight-line distance the box can hold, not any single edge or face measurement.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
Rectangle diagonal formula across a range of widths
A fixed rectangle length of 8, across a range of width values, using the rectangle option.
How does the diagonal differ between a rectangle, square and cube of the same size?
The same 6-unit dimension applied to a rectangle measuring 6 by 6, a square with side 6, and a cube with side 6.
Questions
What is a diagonal?
A diagonal is a straight line connecting two corners of a shape that are not already joined by an edge. In a rectangle there are two, equal in length; in a cube there are both shorter face diagonals and longer space diagonals.
What is the diagonal formula for a rectangle?
d = √(length² + width²), applying Pythagoras across the two sides. For a square, where length and width match, this simplifies to d = side × √2.
How do you calculate the diagonal of a cube?
A cube’s space diagonal, corner to opposite corner through the solid, is d = side × √3. Its shorter face diagonal, across one flat square face, is d = side × √2, the same as a square’s diagonal.
Why is a cube’s space diagonal longer than its face diagonal?
The space diagonal has to cover an extra dimension, cutting through the depth of the cube as well as its length and width, which is why it uses √3 rather than the √2 that covers just two dimensions.
For a rectangle’s area, perimeter and diagonal together, see the rectangle & square calculator. For a rectangular box’s volume, surface area and space diagonal, see the rectangular prism & cube calculator.