Baluster Calculator — Railing Spacing Made Legal

Set the rail run and baluster width — get the count and spacing that keep every opening inside the 4-inch sphere rule.

Baluster Calculator

Paste it on your own page or wiki — no signup, no tracking script.

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

RunBalusters (4 in clear gap)Buy with 10%
6 ft1315
8 ft1820
10 ft2225
12 ft2629
16 ft3539
20 ft4449

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

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.

Figures, formulas and reference tables last checked: 12 October 2026.

FAQ

How many balusters for a 20-foot railing?

With 1½-inch balusters and a 4-inch clear gap: (240 + 4) ÷ 5.5 = 44.36, so 44 balusters fill the run — buy 49 with 10% waste.

What is the 4-inch sphere rule?

It is the building-code limit on guard openings: a 4-inch sphere must not be able to pass through any opening in the guard. It comes from IRC R312.1.3 and applies to the whole guard height, including under the bottom rail.

What is the maximum space between balusters?

The clear gap must be less than 4 inches. A 1½-inch baluster on 5½-inch centres gives exactly a 4-inch clear gap, which is right at the limit — go slightly tighter for margin.

Does the gap under the bottom rail count?

Yes. The 4-inch sphere test applies to every opening in the guard system, including the space between the deck surface and the bottom rail. A bottom rail set more than 4 inches above the deck fails R312.1.3.

Do stairs use the same spacing rule?

No. The triangular opening at the foot of a stair, formed by the riser, tread and bottom rail, must block a 6-inch sphere, and stair guards are tested with a 4⅜-inch sphere. Level guards use the 4-inch sphere.

How many balusters for a 10-foot railing?

At 1½-inch balusters and a 4-inch clear gap: (120 + 4) ÷ 5.5 = 22.55, so 22 balusters fit — buy 25 with waste.

Should I measure centre-to-centre or the clear span?

Use the clear span between the faces of the posts. If you measure post centre-to-centre, subtract the post width before you start, or the end gaps will exceed 4 inches.

How tall must a deck guard be?

At least 36 inches from the walking surface to the top of the top rail where a guard is required, and 34 inches on the open side of a stair, measured from the tread nosing line. A guard is required above 30 inches of fall.

How much extra should I buy?

The calculator adds 10% automatically. It is cheap insurance against a cracked or mis-drilled baluster on installation day, and it covers the visible end or two you may trim to fit.

Do composite railings use the same spacing?

The code still caps the gap at 4 inches, but composite systems often set their own maximum post spacing and baluster width. Check the manufacturer’s instructions — the product only meets the code through its own hardware.

More project calculators

Have a suggestion?

Missing a feature or found something off? Tell us — user suggestions decide what we build next.