Skip to content
HatchCalc

Deck Baluster Calculator

Evenly spaced balusters that pass the 4-inch code rule.

Measured between the two posts, inside face to inside face.

4 in is the common code sphere-rule maximum — edit only if your case differs (e.g. a 6 in stair-triangle rule).

How many railing sections use this same length and layout.

Balusters per section

13balusters

Actual gap3.75 in
Center-to-center spacing5.25 in
First baluster center (from post face)4.50 in
Passes 4 in ruleYes (✓)
Total balusters (all sections)13

The 4-inch sphere rule

Most US residential building codes (based on the IRC) require that a 4 in sphere cannot pass through any opening in a deck or porch guard — including the gaps between balusters. The idea is simple: a 4 in sphere is roughly the size of a small child's head, and if it can't fit through, the child can't get stuck or fall through either.

That 4 in figure is a maximum, not a target to divide by. If you take a railing section and simply divide its length by 4 in, you'll almost never get a whole number of balusters — and whatever fraction is left over usually gets tacked onto one gap, which can quietly push that single gap past 4 in and fail inspection. The fix is to work out how many balusters you actually need first (always rounding up), then spread the leftover space evenly across every gap. That's exactly what the calculator above does, which is why the real spacing it gives you almost always lands a bit under 4 in rather than right at it.

The formula and a worked example

The number of balusters a section needs comes from rounding the theoretical gap count up to a whole number:

Balusters = ceil((Section length − Max gap) ÷ (Baluster width + Max gap))

Once you know the baluster count, the actual (always slightly smaller) gap comes from dividing whatever space is left after the balusters by the number of gaps, which is always one more than the number of balusters (every baluster has a gap on both sides, shared with its neighbors):

Actual gap = (Section length − Balusters × Baluster width) ÷ (Balusters + 1)

Take a 72 in railing section using 1.5 in balusters (standard 2x2 lumber) and the standard 4 in max gap. Balusters = ceil((72 − 4) ÷ (1.5 + 4)) = ceil(68 ÷ 5.5) = ceil(12.36) = 13 balusters. The actual gap is then (72 − 13 × 1.5) ÷ 14 = 52.5 ÷ 14 = 3.75 in — comfortably under the 4 in maximum, and identical at every gap along the section. Add the baluster width to that gap and you get the center-to-center spacing, 1.5 + 3.75 = 5.25 in, which is the number you'll actually use when marking layout points on the rail.

Laying it out without doing math on a ladder

Once you have the numbers, you don't need to recalculate anything while you're actually building. Mark the center of the first baluster at the "first baluster center" distance from the post face (spacing + half the baluster width — 4.5 in in the worked example above), then move down the rail marking every following center at the center-to-center distance (5.25 in in that example). Every mark after the first is the same distance from the one before it, so you're just walking a tape measure down the rail and making a pencil mark at each interval.

An even faster approach for a long run of railing is to cut a spacing jig — a scrap block cut to the exact actual gap width (3.75 in in the example). Set each new baluster against the jig, butted up to the previous one, and you get identical spacing without measuring or marking at all, which is both faster and more consistent than working from a tape measure and a pencil.

Common mistakes to avoid

Measuring post-to-post instead of the clear opening. Enter the section length as the distance between the inside faces of the posts, not center to center. Posts are commonly 3.5 to 5.5 in wide, so using the center-to-center distance overstates how much room you actually have and throws off both the baluster count and the spacing.

Forgetting the rule also applies under the bottom rail.The 4 in sphere rule doesn't just apply between balusters — it also applies to the gap between the deck surface (or bottom rail) and the underside of the guard system. A baluster layout can pass perfectly between balusters and still fail inspection if the bottom gap is too tall, so check that measurement separately.

Assuming the maximum gap is always 4 in. Guards around decks and porches generally use the 4 in figure, but some jurisdictions and some situations — like the triangular opening at open stair treads — use a different maximum (commonly 6 in for that specific triangle). This calculator lets you edit the max gap for exactly that reason, but always confirm the correct number with your local building department before you build.

Frequently asked questions

How far apart should deck balusters be?

Deck balusters need to be spaced so a 4 in sphere can't pass between them, per the sphere rule used in most US residential codes (IRC). In practice that means the actual gap is usually a bit under 4 in — commonly landing around 3.5 to 3.75 in — because you round up to a whole number of balusters first and then divide the leftover space evenly, which produces a gap slightly smaller than the 4 in maximum rather than exactly 4 in.

How many balusters per foot?

For 1.5 in balusters (standard 2x2 lumber) spaced at the maximum allowed 4 in gap, one baluster-and-gap pitch is 5.5 in, so 12 ÷ 5.5 ≈ 2.2 balusters per linear foot is a reasonable rule of thumb for rough material estimating — commonly rounded to about 2 per foot. Real layouts usually need a little more once you account for even spacing and exact post positions, so use this for a quick material guess, not a final cut list.

Does the 4 inch rule apply to stairs?

The 4 in sphere rule still applies to the vertical balusters in a stair guard (the railing running alongside the stairs). But the triangular opening formed by the tread, riser, and bottom rail on open stairs typically uses a looser 6 in sphere rule in most US codes, since that triangle is a different shape and harder for a small child to squeeze through. Always confirm both figures with your local building department, since amendments vary by jurisdiction.

How do I get even spacing?

Instead of dividing your railing length by 4 in and hoping for a whole number, calculate the actual number of balusters that fit (always rounding up), and let that whole number set the exact spacing — which comes out slightly under 4 in and identical between every baluster. Mark the first baluster center at the offset this calculator gives you, then move down the rail marking every following center at the center-to-center distance, so small measuring errors don't stack up baluster by baluster.

Why can't I just divide the section length by 4 inches?

Dividing by 4 in tells you roughly how many gaps could fit, but it almost never lands on a whole number of balusters, and any leftover space usually gets added onto one gap — which can push that single gap over the 4 in limit. Rounding the baluster count up first and then spreading the remaining space evenly across every gap keeps every gap under 4 in and identical, instead of one oversized gap that fails inspection.

Does this account for the post width?

No — enter the section length as the clear opening between posts (inside face to inside face), not post center to post center. Posts are typically 3.5 to 5.5 in wide themselves, so using center-to-center measurements would overstate the space actually available for balusters and throw off both the count and the spacing.

Related tools