StatGardenREF. DESK
Calculators/Geometry/Diagonal
Geometry

Diagonal calculator

Diagonal length of a rectangle, square or cube from its side lengths.

Published 21 August 2026

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

FormulaRectangle: d = √(l²+w²); Square: d = s√2; Cube: d = s√3

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.

TermMeaning
DiagonalA straight line joining two corners that are not already connected by an edge.
Face diagonalOn a cube, the diagonal across one flat square face, equal to side × √2.
Space diagonalOn a cube, the diagonal running from one corner straight through the solid to the opposite corner, equal to side × √3.

The inputs explained

FieldWhat to enter
ShapeChoose 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.

Length fixed at 8, across a range of widths
WidthDiagonalArea
28.24616.000
48.94432.000
610.00048.000
811.31464.000
1012.80680.000
The diagonal grows more slowly than either side, since it follows the square root of the sum of the squares: widening from 2 to 10 at a fixed length of 8 takes the diagonal from 8.246 up to only 12.806, while the area more than quadruples over the same range, from 16.000 to 80.000.

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.

Dimensions of 6 by 6 (or side 6) compared across all three shapes
ShapeDiagonal
Rectangle8.485
Square8.485
Cube10.392
A 6-by-6 rectangle and a square with side 6 are actually the same flat shape, so both give the identical diagonal of 8.485; a cube with side 6 instead reports its longer space diagonal, 10.392, since that line cuts straight through the solid rather than lying flat across one face.

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.