Baluster Spacing and the 4 Inch Sphere Rule, With the Math
How to find the baluster count and equal gap between posts, what IRC R312.1.3 and other codes allow, marking a layout and spacing balusters on a stair rake.
By Redbison Dev · · Updated · 9 min read

A railing with uneven gaps looks wrong from across the yard, and one with a gap too wide fails inspection. Both problems come from the same habit: starting at one post, stepping off "4 inches and a baluster" and taking whatever is left at the other post. The fix is to decide the number of balusters first, then divide the leftover space evenly. This post derives the formula, explains what the codes actually limit, shows how to mark a layout without accumulating error, and works through stair rails, where the spacing along the rail differs from the gap that counts. The Baluster Spacing Calculator does every step.
What the 4 inch rule says
In the US, the International Residential Code (Section R312.1.3) requires that openings in a required guard do not allow a 4 in diameter sphere to pass through. The rule exists because a small child's head is about that size. Two exceptions matter for railings:
- On the open sides of stairs, the guard may allow a 4-3/8 in sphere but not larger.
- The triangle formed by a stair riser, tread and the bottom rail of the guard may allow a 6 in sphere.
Other codes use metric limits. In England, Approved Document K uses 100 mm for dwellings, as does the National Building Code of Canada. Australia's National Construction Code uses 125 mm. Commercial buildings under the IBC also use 4 in for most guards. A sphere test is about the clear opening, so a gap of exactly 4 in is at the limit; in practice builders aim a little under, because balusters are rarely perfectly straight and a slightly bowed one can open a gap.
Counting balusters
Suppose there are n balusters of width b in a clear length L between the faces of two posts. Every baluster has a gap on each side, so there are n + 1 gaps, all equal:
gap = (L - n x b) / (n + 1)
Requiring that gap to be no larger than the limit g and solving for n gives the smallest number that works:
n = ceil( (L - g) / (b + g) )
Take an 8 ft deck section, 96 in between posts, with 2x2 balusters (1-1/2 in actual) and a 4 in limit. Then n = ceil((96 - 4) / 5.5) = ceil(16.73) = 17 balusters, and the gap is (96 - 17 x 1.5) / 18 = 70.5 / 18 = 3.917 in, just under 3-15/16.
The on-centre spacing is the baluster width plus one gap, 5.417 in, and the first baluster's centre sits one gap plus half a baluster from the post: 3.917 + 0.75 = 4.667 in.
Marking the layout without creeping error
Stepping off 5-7/16 in seventeen times from one post adds the rounding error each time: 5-7/16 is 5.4375, about 0.02 in more than the true spacing, so after seventeen steps the last baluster is a third of an inch out. Instead, hook the tape on one post and mark each centre at its cumulative distance: 4.667, 10.083, 15.5, 20.917 and so on, rounding each to the nearest sixteenth. The calculator's layout table lists all of them. A story pole, a scrap strip marked once and used on every identical section, is even faster.
If there are several sections of different lengths, work each one separately. The gaps will differ slightly from section to section, but each section will look even, which is what the eye notices.
Choosing baluster width and the limit
Thicker balusters reduce the count. With 1-1/4 in balusters on the same 96 in rail, n = ceil(92 / 5.25) = 18. Turned or square balusters with a decorative profile should be spaced on their widest part, because the sphere passes the narrowest gap between two neighbours. If the rail will be inspected strictly, set the limit to 3-7/8 or 3-3/4 in in the calculator; a 72 in section with 2-1/2 in turned balusters and a 3-7/8 in limit needs 11 balusters with 3.71 in gaps.
Metric rails work the same way. A 2,400 mm section with 41 mm balusters under a 100 mm limit needs ceil(2,300 / 141) = 17 balusters with 94.6 mm gaps.
Stair rails: measure the gap level
On a stair the balusters stay vertical while the rail slopes. The sphere passes horizontally between two vertical balusters, so the gap that matters is the level distance between them, not the distance along the rail. Work in the level run:
level length = length along the rail x cos(rake)
spacing along the rail = level spacing / cos(rake)
A stair with 7-3/4 in risers and 10 in treads rakes at atan(7.75 / 10) = 37.8 degrees. A rail 120 in long between newels covers 120 x cos 37.8° = 94.85 in of level run. Under a 4 in limit that fits 17 balusters with 3.85 in level gaps; the centres are 5.42 in apart level, which is 6.77 in along the rail where you mark them. If you use the IRC's 4-3/8 in allowance for the open side of stairs, the same rail needs 16.
Many stair balusters are placed by tread instead: two per tread on a 10 in run is a 5 in level spacing, and three per tread on deep treads. Check that the resulting gap is within the limit for your baluster width; two 1-1/4 in balusters per 10 in tread leave 3.75 in gaps, which passes.
What spacing does not cover
Guard height is a separate requirement: 36 in for most residential guards under the IRC and 42 in under the IBC and many local codes. Handrails have their own height, grip size and continuity rules. Horizontal infill such as cable or boards is subject to the same sphere rule but also to climbability concerns in some jurisdictions, and cable needs tension to keep a 4 in sphere out under load. Posts and their connections carry the guard load and are designed under the code's load requirements, not by spacing.
Related tools and reading
The deck the railing sits on is covered in Estimating a Deck: Boards, Joists, Screws and Span Tables and the Deck Calculator. The Stair Calculator gives the riser and tread that set the rake angle, and the Fraction Calculator turns decimal marks into sixteenths. If the rail cap meets at an angle, Crown Molding Angles and Miter Math explains the miter.
Frequently asked questions
Why is the baluster spacing rule 4 inches?
The IRC's 4 inch sphere rule, in Section R312.1.3, exists because a small child's head is about 4 inches across, so openings in a required guard must not let a 4 in sphere pass. Builders aim a little under 4 in, because balusters are rarely perfectly straight and a slightly bowed one can open the gap.
How do I mark baluster spacing without errors adding up?
Hook the tape on one post and mark each baluster centre at its cumulative distance, rounding each to the nearest sixteenth, rather than stepping off the same spacing repeatedly. Stepping off 5-7/16 in seventeen times on an 8 ft rail leaves the last baluster about a third of an inch out. A story pole is even faster for identical sections.
How many balusters per stair tread?
Two balusters per tread is common: on a 10 in tread run that gives a 5 in level spacing, and deep treads may take three. Check the resulting gap against the limit for your baluster width; two 1-1/4 in balusters per 10 in tread leave 3.75 in gaps, which passes the 4 inch rule.
How tall does a deck railing have to be?
Guard height is a separate requirement from baluster spacing: 36 in for most residential guards under the IRC and 42 in under the IBC and many local codes. Handrails have their own height, grip size and continuity rules, and posts and their connections are designed to the code's load requirements.
How should I space turned or decorative balusters?
Space turned or decorative balusters on their widest part, because the sphere passes through the narrowest gap between two neighbours. For strict inspections, use a limit below 4 in: a 72 in section with 2-1/2 in turned balusters and a 3-7/8 in limit needs 11 balusters with 3.71 in gaps.
Sources and further reading
- 2021 International Residential Code, Chapter 3: Building Planning, International Code Council. Section R312 on guards and the 4 in sphere rule.
- Protection from falling, collision and impact: Approved Document K, UK Ministry of Housing, Communities and Local Government. England's 100 mm guarding rule.
- National Construction Code, Australian Building Codes Board. Australia's balustrade rules.
- Prescriptive Residential Wood Deck Construction Guide (DCA 6), American Wood Council. Guard post and baluster details for decks.
Open the Baluster Spacing Calculator
More Carpentry & Woodworking
Every tool in the Carpentry & Woodworking section, free and in your browser.