Rectangular Prism and Cube Calculator

Pick a box or a cube, enter the edges in your unit, and get the volume, surface area, corner-to-corner diagonal and how many gallons or litres it holds.

Labels the lengths; the capacity in gallons and litres is converted from the cubic unit.
Used for a cube.
Used to find a cube's edge; in the cubic unit.
Used to find a cube's edge; in the square unit.

Length

4 ft

Width

3 ft

Height

2 ft

Volume

24 ft³

Surface area

52 ft²

Space diagonal

5.3852 ft

Capacity

179.53 US gal

Capacity

679.6 L

How it works

A rectangular prism, or box, has six rectangular faces meeting at right angles. Its volume is simply length times width times height. Its surface area is the sum of the six faces, which come in three matching pairs: two of length by width, two of length by height and two of width by height. The space diagonal runs from one corner to the opposite corner through the inside of the box, and the Pythagorean theorem applied twice gives it as the square root of the three edges squared and added.

A cube is the special case where all three edges are the same length a, so the volume is a cubed, the surface area is six squares of a squared, and the diagonal is a times the square root of three. Because each of those is a one-line function of a, the calculator can also run them backwards: the cube root of a volume, or the square root of a sixth of a surface area, recovers the edge.

The unit you pick only labels the lengths, areas and volumes; the geometry is the same whatever the unit. The capacity line is where the unit matters: the volume in cubic inches, feet, yards, centimetres or metres is converted to US gallons and litres using the legal definitions of those units, so a one-foot cube reports 7.48 gallons and a one-metre cube 1,000 litres.

Formula

V  = l × w × h
SA = 2(lw + lh + wh)
d  = √(l² + w² + h²)
cube: V = a³   SA = 6a²   d = a√3   a = ∛V = √(SA ÷ 6)
capacity: 1 US gal = 231 in³ = 3.785411784 L;  1 ft³ = 7.48052 gal;  1 m³ = 1,000 L

Example

A box 4 ft long, 3 ft wide and 2 ft high has a volume of 4 × 3 × 2 = 24 ft³, a surface area of 2 × (12 + 6 + 8) = 52 ft², and a space diagonal of √(16 + 9 + 4) = √29 ≈ 5.3852 ft. Filled with water it would hold 24 × 7.48052 ≈ 179.53 US gallons, or 679.60 litres.

A cube with 1 ft edges has a volume of exactly 1 ft³, which is 7.48 US gallons or 28.32 litres, a surface area of 6 ft², and a diagonal of √3 ≈ 1.7321 ft. Running it the other way, a cube whose volume is 27 ft³ has edges of ∛27 = 3 ft and a surface area of 6 × 9 = 54 ft².

Assumptions and limitations

  • Every face meets its neighbours at right angles, so the solid is a true box. A skewed box (a parallelepiped) has the same volume but a different surface area and diagonal.
  • All edges are in the unit you chose, and the capacity assumes the whole interior volume is usable. A real tank, aquarium or crate holds less once wall thickness, headspace and fittings are taken out.
  • The gallon is the US liquid gallon of 231 cubic inches, not the imperial gallon.
  • Results are rounded for display only.

Frequently asked questions

How many gallons does a cubic foot hold?

7.48 US gallons. A cubic foot is 12 × 12 × 12 = 1,728 cubic inches, and a US gallon is defined as 231 cubic inches, so 1,728 ÷ 231 = 7.4805. The same cubic foot is 28.32 litres.

Why does the diagonal matter?

It is the longest straight line that fits inside the box. If you are checking whether a rod, pipe or board can be packed diagonally inside a crate, or whether a case fits through an opening on the slant, the space diagonal is the number to compare.