What the animation shows
The animation and the step-by-step video above use your numbers. Here is the same walkthrough written out for the default example.

What you enter
- Total railing length: 40 ft.
- Maximum post spacing: 6 ft.
- Post width: 3.5 in.
- Baluster width: 1.5 in.
- Maximum clear gap: 3.875 in. Code requires that a 4 in sphere cannot pass. 3⅞ in leaves a margin.
What happens, step by step
- Posts go up first, at most 6 ft apart, splitting the rail into sections.
- Balusters fill each section, spaced so every gap is the same.
- 12 per section leaves 3.58 in gaps, under your 3 7/8 in limit.
- A 4 in sphere cannot slip through, so the spacing passes.
The answer: balusters is 84.
How it’s calculated
- Sections = length ÷ max post spacing, rounded up; posts = sections + 1
- Clear section = (length − posts × post width) ÷ sections
- Balusters per section = (clear − gap) ÷ (baluster + gap), rounded up
- Actual gap = (clear − balusters × width) ÷ (balusters + 1)
Worked example
40 ft of railing, posts at most 6 ft apart, 4×4 posts, 1½ in balusters.
Inputs
- Total railing length
- 40 ft
- Maximum post spacing
- 6 ft
- Post width
- 3.5 in
- Baluster width
- 1.5 in
- Maximum clear gap
- 3.875 in
Results
- Balusters
- 84
- Posts
- 8
- Sections
- 7
- Balusters per section
- 12
- Actual gap
- 3.58 in
Assumptions and limits
- Straight run with equal sections. Corners and stair rails change the count.
Verify the result against the applicable local code, adopted code edition, manufacturer instructions and project requirements. See our methodology.
Questions
What is the 4 inch rule for balusters?
Residential codes generally require that a 4 in sphere cannot pass through guard openings. Keeping gaps a bit under 4 in allows for wood movement.
How many balusters per foot?
With 1½ in balusters and gaps just under 4 in, expect about 2.2 per foot of clear railing.