Baluster spacing is a safety rule, not a preference
Railing infill is governed by one number that comes straight from the building code: the opening between balusters has to be small enough that a 4-inch sphere cannot pass through it. The rule exists because that sphere is about the size of a small child's head, and the gap it stops is the space a child could slip through. This calculator takes your rail run, your baluster width and the gap you want, and returns the count that fills the run with every opening legal.
Spacing is not something to eyeball. A run that is a few inches off ends in a gap you cannot close without re-cutting, and because the limit is a maximum, the error goes in one direction only — too wide is a failed inspection.
What the code actually says
The requirement sits in the International Residential Code at Section R312.1.3, "Opening limitations". The model text reads: required guards shall not have openings from the walking surface to the required guard height that allow passage of a sphere 4 inches (102 mm) in diameter. State and local adoptions carry the same wording.
Two exceptions are easy to trip over. The triangular opening at the foot of a stair — formed by the riser, the tread and the bottom rail — must instead block a 6-inch sphere, and guards along the open side of a stair are tested with a 4⅜-inch sphere. Everywhere else on a level guard it is four inches, and the test applies to every opening in the guard, including the gap under the bottom rail, not only the spaces between balusters.
How the count is worked out
The calculator counts balusters against a fixed gap. In words, it asks how many baluster-plus-gap units fit into the run, with one extra gap to close the last opening:
balusters = floor( (run in inches + gap) ÷ (baluster width + gap) )
Each baluster and the gap beside it form a repeating unit of (width + gap). The run, plus one extra gap, is divided by that unit and rounded down, because a part-unit at the end does not become a whole baluster. The result already includes the two end balusters that sit against the posts. The calculator then adds 10% for waste — that is what you buy rather than what you fit, so a cracked baluster on installation day does not stop the job.
Clear gap versus on-centre spacing
Two ways of describing the same layout get confused constantly, so it is worth pinning down. The clear gap is the open space between the faces of two balusters — the space the 4-inch sphere tests. The on-centre spacing is the distance from the centre of one baluster to the centre of the next. They are never the same number: on-centre distance is always the clear gap plus the baluster width.
A 1½-inch baluster on a 4-inch clear gap sits on 5½-inch centres. So "set the centres 5.5 inches apart" and "set the gaps at 4 inches" describe the identical rail — but quoting the wrong one can double the count. This calculator works from the clear gap, because the clear gap is the number the code limits.
Three worked examples
A 20 ft deck rail, 1½ inch balusters, 4 inch gaps
The run is 240 inches. The unit width is 1.5 + 4 = 5.5 inches, plus one extra gap: (240 + 4) ÷ 5.5 = 44.36, which floors to 44 balusters. Add 10% and you buy 49.
A 10 ft porch rail, 1½ inch balusters
120 inches gives (120 + 4) ÷ 5.5 = 22.55, which floors to 22 balusters — 25 to buy with waste.
An 8 ft front-porch rail, 2 inch square balusters
96 inches with a wider baluster: (96 + 4) ÷ (2 + 4) = 16.67, which floors to 16 balusters, 18 to buy. The wider the baluster, the fewer you need, because the unit eats more of the run.
Compare the first two: halving the run does not halve the count. It falls from 44 to 22 because the count is the floor of a division, not a proportion — short runs carry proportionally more waste, which is why per-segment measuring matters.
Count by run length, at 1½ inch balusters
| Run | Balusters (4 in clear gap) | Buy with 10% |
|---|---|---|
| 6 ft | 13 | 15 |
| 8 ft | 18 | 20 |
| 10 ft | 22 | 25 |
| 12 ft | 26 | 29 |
| 16 ft | 35 | 39 |
| 20 ft | 44 | 49 |
The counts do not climb in a straight line with the run length — read the table and you can see it is the floor of a division, so a run a few inches longer sometimes needs no extra baluster and sometimes needs one more. That is exactly why a span table is a guide and the calculator is the answer.
Measure each segment, not the whole rail
Balusters run between posts, so measure post to post, run the calculator segment by segment, and add the counts. A long rail broken by mid-posts is several short runs, not one long one — and because the count is floored, treating it as one run leaves you short on some sections.
Post width matters too. If the run you enter is the clear distance between the faces of two posts, the end balusters land flush and every opening closes correctly. If you measure centre-to-centre instead, subtract the post width before you start, or the first and last gaps will come out wider than 4 inches — the most common field error, and one an inspector finds immediately.
Spacing is only half the rule
Baluster spacing gets the attention, but the same code section governs the guard as a whole. A guard is required wherever an open-sided walking surface sits more than 30 inches above the floor or grade below. Where a guard is required it must be at least 36 inches tall, measured from the walking surface to the top of the top rail — a cap rail counts as the top. On the open side of a stair the minimum drops to 34 inches, measured from the line connecting the tread nosings.
Those heights do not change the baluster count directly, but they are checked at the same inspection, and a rail built to the wrong height is not rescued by perfect spacing.
Materials and how many to carry
Balusters are sold individually in wood and in fixed packs, sections or by the linear foot in composite, aluminium and cable systems. Wood balusters are commonly 1½ inches square — the actual size of a nominal 2 × 2 — with wider turned profiles available. Composite systems often set their own maximum spacing and their own baluster width, so check the maker's instructions before running the count: the code caps the gap, but a product can only promise the code through its own hardware.
Carry the 10% the calculator adds. Balusters are cheap next to a second trip, and a job stopped one baluster short with the holes already drilled is the worst kind of delay. Keep a few spares from the same batch — like tile, balusters can vary slightly between production runs.
Where the count usually goes wrong
- Measuring centre-to-centre. Post centrelines include the post width. Measure the clear span between posts instead, or subtract the post width first.
- Counting only the middles. The formula counts the end balusters too. Dropping them leaves the two openings against the posts too wide.
- Mixing up clear gap and on-centre spacing. They differ by the baluster width, so a 4-inch gap is not a 4-inch centre spacing.
- Ignoring the gap under the bottom rail. The 4-inch sphere test covers every opening in the guard, including the space between the deck surface and the first rail.
- Rounding down. The count is already floored, so it is the minimum that closes every gap. Never take a baluster out of it.
Sources and standards
Where these figures come from
Every formula on this page is implemented from the published reference material below, and every worked example was produced by running the calculator itself rather than by hand. Where a value depends on a regional code, the calculator lets you override it rather than assuming one jurisdiction.
- ICC Digital Codes — International Residential Code, Section R312.1.3 (Opening limitations) — the model code text requiring guard openings to reject a 4-inch sphere, with the 6-inch stair-triangle and 4-3/8-inch stair-guard exceptions.
- Town of Easton, MD — 2018 IRC Deck Packet — a permitted-set copy of the IRC deck and guard provisions, including R312.1.1 guard trigger, R312.1.2 height and R312.1.3 openings.
- American Wood Council — the DCA 6 prescriptive residential wood deck construction guide, span tables and lumber design values referenced for deck guards.
- APA — The Engineered Wood Association — panel and engineered-wood guidance for deck framing and railing installation.
Figures, formulas and reference tables last checked: 12 October 2026.