Baluster Spacing Calculator

Enter the clear run between the end posts and the actual width of one baluster. This returns the number of balusters, the on-centre spacing to mark on the rail, and the clear gap you will actually get — checked against the IRC 2021 4-inch sphere rule, including the 4⅜-inch allowance on stair guards.

Between the two end posts
Add the odd inches here
Measure one baluster, not the nominal size
The sphere test, not the baluster
36 to the top of the rail; 34 is the minimum on the open side of stairs
Balusters needed17
On-centre spacing to mark5.42″ o.c.
Clear gap you get3.917″ ≤ 4″
Widest legal on-centre spacing5.5″ o.c.
Gap at each end of the run3.917″
Balusters per foot of rail2.18
Baluster stock at 36″17 × 36″ = 51 ft

96″ of rail holds 17 balusters and 18 equal gaps of 3.917″, which is inside the 4″ limit of R312.1.3 for a level guard. Keep the bottom rail within 4″ of the deck — the sphere test runs from the walking surface, not from the bottom rail.

How baluster spacing is calculated

A guard rail has three things in it: balusters, the gaps between them, and the gaps at the two ends. The code does not care about on-centre spacing at all — it cares about the size of the hole. IRC 2021 R312.1.3 says a guard shall not have openings from the walking surface to the required guard height that allow passage of a 4-inch sphere. So the layout question is: how many pieces of baluster can I stand in this run and still leave every gap under 4 inches?

The formula
N = ceil((L − c) ÷ (w + c))
gap = (L − N·w) ÷ (N + 1)
on-centre = gap + w

L is the clear length of the rail, c is the largest legal clear opening (4″ level, 4⅜″ on stairs) and w is the actual width of one baluster. The first line works because N balusters and N + 1 gaps have to fit inside L: N·w + (N + 1)·c ≤ L, which rearranges to the expression above. Rounding up is what guarantees the last gap is not wide — rounding to the nearest number is how a rail ends up with a 5-inch hole.

The second line spreads the leftover length evenly over the N + 1 gaps, so the two end gaps match the gaps in the field. The third line converts the gap into the number you actually mark with a tape: the distance from the centre of one baluster to the centre of the next. Note that on-centre spacing is always larger than the clear gap, by exactly one baluster width — which is why "5½ inches on centre" is the same instruction as "4 inches clear" for a 1½-inch baluster, and a completely different hole for a ¾-inch metal one.

Worked example: an 8 ft rail with 1½″ balusters

A deck guard with posts 8 ft apart, so the clear run between them is 96 inches. The balusters are 2×2 nominal, 1½ inches actual. The guard is level, so the limit is 4 inches.

Now check the arithmetic from the other side, which is how you catch a mistake: 17 balusters at 1.5 inches is 25.5 inches of solid material, and 18 gaps at 3.917 inches is 70.5 inches of air. The two add to 96 inches exactly. If your numbers do not add back to the rail length, the count or the gap is wrong.

A cleaner example to keep in your head is a 4 ft (48″) rail with 1½″ balusters. It works out perfectly: 8 balusters and 9 gaps of exactly 4.000 inches, because 8 × 1.5 + 9 × 4 = 12 + 36 = 48. That is the code limit exactly, with no margin, so in practice you would use 9 balusters there and get 3.6-inch gaps — a hair of tolerance costs one baluster and saves an inspector argument.

Baluster count by rail length

The table runs the formula for common post spacings at the three baluster widths sold for deck guards, level guard, 4-inch limit. Every count is the minimum that passes; they are not rounded to a pretty number.

Balusters needed per rail run, IRC 2021 R312.1.3 level guard (4″ clear), equal gap at each end
Rail run¾″ metal1½″ (2×2)2″ square
4 ft (48″)1088
6 ft (72″)151312
8 ft (96″)201716
10 ft (120″)252220
12 ft (144″)302624
16 ft (192″)403532
20 ft (240″)504340

Read the 10 ft row as a sanity check: 22 balusters at 1½ inches. 22 × 1.5 = 33 inches of baluster in a 120-inch run leaves 87 inches over 23 gaps = 3.78 inches each. Note how flat the count is per foot — 1½-inch balusters run about 2.18 per foot at the limit, so a 30 ft run of rail is roughly 66 balusters and you can estimate an order from the linear footage before you have measured a single bay.

Widest on-centre spacing by baluster width

On-centre spacing is the clear limit plus the baluster width, so this table is the shortcut version of R312.1.3. Use it when you are marking the rail and want one number to step along with a tape.

Maximum baluster spacing (inches on centre) from the IRC 2021 sphere limits — derived: clear limit + baluster width
Baluster width (actual)Level guard — 4″ clearStair guard — 4⅜″ clear
¾″ metal baluster4.75″5.125″
1½″ wood (2×2)5.5″5.875″
2″ square baluster6″6.375″
2½″ turned baluster6.5″6.875″
3″ post sleeve / large baluster7″7.375″

Two things this table shows that on-centre rules of thumb hide. A 2×2 baluster at 5½ inches on centre is legal; a ¾-inch metal baluster at 5½ inches on centre is not, because the same on-centre distance leaves a 4¾-inch hole. The gap is what the code measures, so always convert: clear = o.c. − baluster width.

The gap at each end of the run counts

R312.1.3 does not say "the openings between balusters". It says openings from the walking surface to the guard height, full stop, and the space between an end post and the first baluster is one of those. This is where most self-built rails fail: the installer hooks the tape on the first post, marks 5½ inches, and steps along the rail. Seventeen marks later the last baluster lands wherever the fractional remainder left it, and the gap at the far post is 6 or 7 inches.

The fix is to divide the run rather than step along it. Take the total clear length, subtract the baluster widths, divide by the number of gaps (balusters + 1), and mark that gap from each end. Every gap then matches, both ends included, and the layout closes correctly at the far post. This calculator does that division: the "gap at each end" row is the same number as the field gap by construction.

Layout rule: balusters = ceil((L − 4) ÷ 5.5) for 2×2 stock, and the gap you mark is (L − 1.5 × balusters) ÷ (balusters + 1). Never lay out from one end with a fixed step.

The under-rail gap: the sphere test starts at the deck

"Opening" includes the space under the bottom rail. A guard with perfectly spaced balusters and a bottom rail 7 inches off the deck has a 7-inch opening along its whole length, and a 4-inch sphere passes through it easily. Keep the bottom rail within 4 inches of the walking surface — on a stair guard, within 4⅜ inches measured perpendicular to the nosing line — and treat it as one more baluster lying on its side.

The same logic applies at the top. The guard height must be at least 36 inches measured to the top of the rail, and there must be no opening between the top rail and the guard height. A 42-inch post carrying a rail at 34 inches fails on height even though the post looks tall.

Stairs: 4⅜ inches and the 6-inch triangle

Guards on the open side of stairs get two exceptions, and they are the reason a stair rail can look slightly looser than a level one.

Everything else carries over: the gap at the bottom of the guard still counts, the run still gets equal gaps at both ends, and the height is measured from the line connecting the nosings — 34 inches minimum, or 34 to 38 inches where the guard top doubles as the handrail. Switching this calculator to the stair mode changes the limit to 4⅜ inches and recomputes the count, which typically saves one baluster per 8 ft run and gives you a little margin on the slope.

Height, and when a guard is required at all

The spacing rules only apply once a guard is required, and the trigger is in R312.1.1: an open-sided walking surface — floor, stair, ramp or landing — more than 30 inches above the floor or grade below, measured at any point within 36 inches horizontally of the open edge. A deck 28 inches off the ground needs no guard under the IRC; at 31 inches it needs one, even if the drop is only at one corner. Insect screening explicitly does not count as a guard.

Where a guard is required, R312.1.2 sets the height at not less than 36 inches above the adjacent walking surface or the line connecting the nosings, and on the open side of stairs at not less than 34 inches. If the top of the guard is also the handrail on stairs, it must be 34 to 38 inches above the nosing line — a narrower band than the level guard, because a handrail you cannot grip at the right height is a different failure. Measure to the top of the rail. The post almost always extends past it.

Marking the rail without cumulative error

Stepping a tape along a rail accumulates every rounding error into the last bay. Mark from both ends instead, or better, mark the baluster centres by dividing the run into equal parts with a calculator rather than a tape.

Common mistakes

Baluster spacing FAQ

How far apart should balusters be?

Leave no more than 4 inches of clear opening between balusters on a level guard, and no more than 4⅜ inches on the open side of a stair (IRC 2021 R312.1.3 and its second exception). Converted to on-centre spacing that is 5½ inches for 1½-inch balusters, 4¾ inches for ¾-inch metal balusters and 6 inches for 2-inch balusters, because on-centre spacing is the clear gap plus one baluster width.

How many balusters do I need for an 8 foot railing?

Seventeen 1½-inch balusters over a 96-inch run. (96 − 4) ÷ (1.5 + 4) = 16.7, rounded up to 17, which leaves 18 gaps of (96 − 17 × 1.5) ÷ 18 = 3.92 inches each. With ¾-inch metal balusters the same 8 ft run takes 20, and with 2-inch balusters it takes 16.

Does the gap at the end of the rail count as an opening?

Yes. R312.1.3 limits every opening from the walking surface up to the guard height, and the space between an end post and the first baluster is one of them. If the balusters are laid out from one end at 5½ inches on centre, the far end can be left wide open — which is the most common way a rail that looks correct fails inspection. Spread the run so both end gaps equal the gap between balusters.

Is the limit 4 inches or 4⅜ inches?

Four inches on a level guard; 4⅜ inches is an exception that applies only to guards on the open side of stairs. The 4⅜ figure is measured on the sloped rail, which is why it is slightly larger than the level limit. There is also a 6-inch allowance for the triangular opening formed by the riser, tread and bottom rail at the open side of a stair — that is a separate exception for one specific opening, not a general rule.

How high can the bottom rail be above the deck?

No more than 4 inches, because the sphere test applies from the walking surface up to the guard height. A bottom rail set 6 or 8 inches up to look cleaner leaves a gap that a 4-inch sphere passes straight through, and it is the second most common guard failure after the end gap. Treat the bottom rail as a baluster laying on its side.

How tall does a deck guard have to be?

Not less than 36 inches above the adjacent walking surface, measured to the top of the rail (R312.1.2). On the open side of stairs the minimum is 34 inches measured from the line connecting the nosings, and where the top of the guard also serves as the handrail on stairs it must be 34 to 38 inches from that line. Measuring to the top of the post instead of the top of the rail is a frequent mistake because the post usually stands above the rail.

When is a guard required at all?

Wherever an open-sided walking surface — a floor, stair, ramp or landing — is more than 30 inches above the floor or grade below at any point within 36 inches horizontally of the open edge (R312.1.1). Below 30 inches no guard is required by the IRC, whatever the deck looks like without one.

Does this work for cable railing?

The arithmetic does, but the limit may not be the code limit. R312.1.3 sets the maximum opening; a cable system's manufacturer usually specifies a tighter vertical spacing, often around 3 inches, for deflection and appearance. Design the frame to the code limit and then follow the manufacturer's spacing for the infill itself.

Where these numbers came from

R312.1, R312.1.1, R312.1.2 and R312.1.3 were read verbatim on 2026-11-18 from the up.codes viewer for the 2021 IRC as adopted in Connecticut (chapter 3, Building Planning), and the opening limits were confirmed against the ICC digital code entry for 2021 IRC R312.1.3, which carries the same 4-inch limit, the 6-inch triangular exception and the 4⅜-inch stair exception. Everything else on this page — the counts, the gaps, the on-centre spacings — is arithmetic on those numbers and can be checked by hand with the formula above. The IRC is adopted state by state and locally amended; some jurisdictions amend guard heights, so your authority having jurisdiction wins. Guard loads, when you are sizing the posts rather than the infill, are 200 lb concentrated and 50 lb on in-fill components per IRC Table R301.5.

This is a working reference, not engineering. A guard is a life-safety system: the frame, the connections and the load path matter as much as the gap. Anything unusual — a long span between posts, a glass or cable infill, a guard carrying a screen wall — needs the manufacturer's system and, where the code does not cover it, a designer.

Related pages