The deck railing calculator counts the balusters a guard section needs so that no gap lets the code's sphere through: 4 inches on a deck and 4⅜ inches along a stair, under the 2024 International Residential Code and California's 2025 edition alike. It gives the gap, the on-center spacing, the total for every section and the guard's height: at least 36 inches on a deck under the model code and in Austin, 42 in California and Los Angeles, and 34 inches along a stair.
It spaces the balusters. It does not size posts, rails or their fastening; those come from a prescriptive guide, the manufacturer or an engineer.
How to use it
- 01
Measure between the posts
The clear distance from post face to post face, where the balusters will go. Sections of different lengths get their own count, so run the calculator once for each length.
- 02
Enter the baluster's width
The face width across the section, such as 1½ inches for a nominal 2×2. The count depends on it.
- 03
Choose where the guard runs, and the code
On a deck the gaps stay under 4 inches; along a stair's open side, under 4⅜. The code sets the deck's guard height: 36 inches under the model code and in Austin, 42 in California and Los Angeles.
- 04
Read the count
Balusters per section, the total for all sections, and the gap and on-center spacing to mark out. Price them at your own number below the result.
How the math works
Balusters
The fewest balusters n that leave every gap under s′, the sphere less 1/32 inch, in a section of length L with balusters of width w: (L − n × w) ÷ (n + 1) < s′, so n = the whole part of (L − s′) ÷ (w + s′), plus one. A 72-inch section of 1½-inch balusters on a deck: (72 − 3 31/32) ÷ 5 15/32 = 12.4, so 13 balusters.
Gap and spacing
Gap = (L − n × w) ÷ (n + 1), the same between balusters and at each post; on center = gap + w. The example leaves 3.75-inch gaps, 5.25 inches on center.
Under the sphere, with room on the tape
A sphere passes any gap at least as wide as itself, so a gap of exactly 4 inches fails; that is why the formula adds one to the whole part instead of rounding up. The 1/32 inch the count keeps in hand means no gap rounds up to the sphere on a tape marked in sixteenths.
Where the number goes wrong
- Leaving 4-inch gaps. A gap exactly as wide as the sphere lets it through; on a deck every gap stays under 4 inches.
- Forgetting the gap under the bottom rail. The sphere rule runs from the walking surface up to the guard's height, so the space between the deck and the bottom rail counts too.
- Using the stair's figures on the deck. The 4⅜-inch gaps and the 34-inch guard apply only along a stair's open side.
- Using the model code's 36 inches in Los Angeles. California's code, which the city adopts, asks for 42 inches on the deck.
- Treating the count as structure. Posts, rails and their fastening come from a prescriptive guide, the manufacturer or an engineer.
Questions people ask
How far apart should deck balusters be?
Close enough that no gap passes a 4-inch sphere on a deck, or a 4⅜-inch sphere along a stair's open side: every clear gap under 4 inches on the deck. With 1½-inch balusters a 72-inch section takes 13, 3.75 inches apart.
How many balusters for an 8-foot section?
17 balusters of 1½ inches, with 3.92-inch gaps, when 96 inches is the clear space between the posts.
How high does a deck railing have to be?
Where a guard is required, at least 36 inches under the model code and in Austin, and 42 in California, Los Angeles included; 34 inches along a stair's open side, measured from the nosings.
When does a deck need a railing?
Where an open side is more than 30 inches above the grade at any point within 36 inches of its edge.