Baluster Spacing Calculator

Balusters needed17
Actual gap between balusters3.92 in
Centre-to-centre spacing5.42 in
Number of spaces18
How this was calculated
  1. Building codes cap the open gap — the IRC's 4-inch sphere rule (section R312) means a 4-inch ball must not pass between balusters. Each baluster plus one gap may therefore span at most 4.00 + 1.50 = 5.50 inches.
  2. Balusters needed = ceil((96.00 − 4.00) ÷ 5.50) = 17.
  3. With 17 balusters there are 18 equal spaces; the actual gap is (96.00 − 17 × 1.50) ÷ 18 = 3.92 inches, and the centre-to-centre spacing is 5.42 inches.

A baluster spacing calculator figures out how many balusters you need for a given run and then divides that run so every gap comes out equal and under the code cap. You enter the run measured between the inside faces of the posts, your baluster width, and the maximum allowed gap. The calculator returns the baluster count and the even gap and center-to-center spacing that result. For instance, a 96-inch run with 1.5-inch balusters and a 4-inch maximum gap needs 17 balusters, giving gaps of 3.92 inches and 5.42 inches center-to-center. A 120-inch run with 3.5-inch balusters needs 16 balusters, with gaps of 3.76 inches. And a 36-inch run with 1.5-inch balusters needs 6 balusters, giving gaps of 3.86 inches — with 5, the gaps would exceed 4 inches and fail.

The method behind this calculator is the accepted standard because it spaces every opening evenly across the whole run instead of repeating a fixed spacing and leaving one wide last gap, which is what keeps every opening code-compliant. Section R312 of the International Residential Code caps guard openings with the 4-inch sphere rule: a 4-inch ball must not pass through any opening in a guard. The baluster count is found using n = ceil((run − max gap) ÷ (max gap + baluster width)); the run is then re-divided so every gap is equal and under the cap. This page shows the formula, step-by-step workings, worked examples, and sources.

Worked examples

A standard deck rail

Primary result: 17 — seventeen balusters over 96 inches gives even gaps of 3.92 inches, safely under the 4-inch cap. (96 in · 1.5 in · 4 in)

Balusters needed17
Actual gap between balusters3.92 in
Centre-to-centre spacing5.42 in
Number of spaces18

Wide balusters

Primary result: 16 — wider balusters need fewer pieces, and the finished gap lands at 3.76 inches. (120 in · 3.5 in · 4 in)

Balusters needed16
Actual gap between balusters3.76 in
Centre-to-centre spacing7.26 in
Number of spaces17

A short section

Primary result: 6 — short runs are where guessing goes wrong: 5 balusters would leave one gap over the limit. (36 in · 1.5 in · 4 in)

Balusters needed6
Actual gap between balusters3.86 in
Centre-to-centre spacing5.36 in
Number of spaces7

The 4-inch sphere rule

Guard openings are capped by the 4-inch sphere rule in section R312 of the International Residential Code: a 4-inch ball must not pass through any opening in a guard. The reasoning is straightforward — the test approximates a small child's head. If a 4-inch sphere cannot pass through, a child cannot get their head stuck between the balusters. That is why every gap in your railing matters, not just most of them.

A common mistake is to repeat a fixed spacing across the run and leave whatever is left over at the end. That last gap is often wider than the rest and can exceed the 4-inch cap. Even spacing across the whole run, instead of repeating a fixed spacing and leaving one wide last gap, is what keeps every opening code-compliant. The baluster spacing calculator on this page handles that for you. It computes the baluster count as n = ceil((run − max gap) ÷ (max gap + baluster width)); the run is then re-divided so every gap is equal and under the cap. Measure the run between the inside faces of the posts.

To see how the math works in practice, take a 96-inch run with 1.5-inch balusters and a 4-inch maximum gap. The formula returns 17 balusters, giving even gaps of 3.92 inches and a centre-to-centre spacing of 5.42 inches. A 120-inch run with 3.5-inch balusters needs 16 balusters, with gaps of 3.76 inches. A 36-inch run with 1.5-inch balusters needs 6 balusters (gaps of 3.86 inches) — with 5, the gaps would exceed 4 inches and fail. Each example stays under the cap because the count is rounded up and the run is then re-divided evenly.

The IRC sets the national baseline, but local codes amend the IRC. Some jurisdictions tighten the maximum gap, apply different rules to stair guards, or add their own requirements. That is why the maximum gap is an input on this page rather than a fixed value. Enter the gap allowed by your local code, and the calculator adjusts the baluster count and spacing to keep every opening compliant.

The even-spacing method

The even-spacing method starts with a ceiling formula that tells you the minimum number of balusters your run needs, then re-divides the leftover space so every gap comes out equal. Measure the run between the inside faces of the posts first, because that is the actual open space you are filling. Guard openings are capped by the 4-inch sphere rule in section R312 of the International Residential Code: a 4-inch ball must not pass through any opening in a guard. The baluster count is n = ceil((run − max gap) ÷ (max gap + baluster width)); the run is then re-divided so every gap is equal and under the cap.

Work through a 96-inch run with 1.5-inch balusters and a 4-inch maximum gap to see the method in action. Plug the numbers into the formula: (96 − 4) ÷ (4 + 1.5) = 92 ÷ 5.5 = 16.73. The ceiling function rounds up to 17 balusters. Now re-divide the run to find the even gap: subtract the total baluster width (17 × 1.5 = 25.5 inches) from the 96-inch run, leaving 70.5 inches of open space. Spread that across 18 gaps — one before the first baluster, one after the last, and one between each pair — and you get 70.5 ÷ 18 = 3.92 inches per gap. The centre-to-centre spacing is 3.92 + 1.5 = 5.42 inches. Every gap sits under the 4-inch cap.

The same steps hold for other runs. A 120-inch run with 3.5-inch balusters needs 16 balusters, with gaps of 3.76 inches. A 36-inch run with 1.5-inch balusters needs 6 balusters, giving gaps of 3.86 inches. Drop that count to 5 and the gaps would exceed 4 inches and fail. The ceiling formula exists to catch that failure before it happens — round down and you are guaranteed a non-compliant opening.

Even spacing across the whole run, instead of repeating a fixed spacing and leaving one wide last gap, is what keeps every opening code-compliant. A baluster spacing calculator that uses this method does the ceiling step and the re-division step for you, so you get a single gap value that applies to every opening. Lay out the first baluster one gap-width in from the post, then step centre-to-centre down the run. The last baluster lands one gap-width from the far post, and no opening is wider than the rest.

Worked examples

The table below shows three verified runs that a baluster spacing calculator should reproduce exactly. Each case starts by measuring the run between the inside faces of the posts, then applies the count formula and re-divides the run so every gap comes out equal and under the 4-inch cap. The count formula is n = ceil((run − max gap) ÷ (max gap + baluster width)). Once the count is set, the run is divided again so the gaps are even across the whole span.

Even spacing across the whole run is what keeps every opening code-compliant. A common mistake is to pick a fixed spacing, lay out balusters one by one, and let the last gap fall wherever it lands. That last gap can end up wider than the rest and exceed the 4-inch sphere rule in section R312 of the International Residential Code, which states that a 4-inch ball must not pass through any opening in a guard. Re-dividing the run after the count is fixed prevents this problem.

The first example is a 96-inch run with 1.5-inch balusters and a 4-inch maximum gap. The formula gives 17 balusters. Re-dividing the run produces even gaps of 3.92 inches and a centre-to-centre spacing of 5.42 inches. The second is a 120-inch run with 3.5-inch balusters, which needs 16 balusters and gives gaps of 3.76 inches. The third is a short 36-inch run with 1.5-inch balusters, which needs 6 balusters and gives gaps of 3.86 inches. With only 5 balusters in that run, the gaps would exceed 4 inches and fail the code rule.

These three cases cover a long run, a medium run with wider balusters, and a short run. In each one the gap stays below 4 inches by a clear margin, and no single gap is wider than another. That is the result a baluster spacing calculator should return for any input.

Run (inches)Baluster width (inches)Max gap (inches)Balusters neededEven gap (inches)Centre-to-centre (inches)
961.54173.925.42
1203.54163.76—
361.5463.86—
Always measure the run between the inside faces of the posts. Measuring to the outside faces or to the center of the posts will throw off the count and the gap size.

Layout tips that keep you legal

A baluster spacing calculator only works if you feed it the right run length. Measure between the inside faces of your posts, not from center to center or from the outside edges. If you measure the wrong span, the calculator will distribute the balusters across a length that does not match your actual framing, and the gaps you cut will not match the gaps you get on the railing.

Newel posts that land mid-run can throw off your count if you treat the whole span as one opening. Each segment between posts is its own run, so calculate each section separately. The same applies to stair sections: the run along a stair rail is longer than the horizontal distance, so measure along the rail itself. Check the bottom-rail and stair openings too, because the 4-inch sphere rule in section R312 of the International Residential Code applies to every opening in a guard, not just the spaces between balusters above the midrail.

The baluster count comes from the formula n = ceil((run − max gap) ÷ (max gap + baluster width)). Once you have the count, the run is re-divided so every gap is equal and under the cap. Even spacing across the whole run, instead of repeating a fixed spacing and leaving one wide last gap, is what keeps every opening code-compliant. A 4-inch ball must not pass through any opening in a guard, so the math has to land every gap at or below that limit.

The verified examples show how the numbers shake out. A 96-inch run with 1.5-inch balusters and a 4-inch maximum gap needs 17 balusters, giving even gaps of 3.92 inches and 5.42 inches centre-to-centre. A 120-inch run with 3.5-inch balusters needs 16 balusters, with gaps of 3.76 inches. A 36-inch run with 1.5-inch balusters needs 6 balusters, with gaps of 3.86 inches — with only 5, the gaps would exceed 4 inches and fail. In every case the equal-gap method keeps the spacing legal where a fixed-spacing approach could leave you with a wide final gap that violates the code.

  • Measure between the inside faces of the posts, not center-to-center.
  • Treat each segment between newel posts as a separate run.
  • Check bottom-rail and stair openings against the same 4-inch sphere rule.
  • Let the calculator re-divide the run for even gaps rather than repeating a fixed spacing.
A 4-inch ball must not pass through any opening in a guard under section R312 of the International Residential Code. Measure every gap after installation to confirm compliance.

FAQs

What is the 4-inch sphere rule?

The IRC guard rule states that no opening in a guard may let a 4-inch sphere pass through. This means the clear gap between your balusters must stay under 4 inches everywhere along the run. It is the key safety standard the calculator uses to check your spacing and confirm your layout will pass inspection.

How far apart should deck balusters be?

Close enough that the clear gap never reaches 4 inches. On the verified 96-inch run with 1.5-inch balusters, that means 17 balusters at 3.92-inch gaps. The calculator finds the count and spacing that keeps every gap below the limit while distributing leftover space evenly across the whole run.

Why not just space balusters every 5.5 inches?

A fixed spacing usually leaves one wider final gap, which is the opening that fails inspection. When you lock in a set distance, the remainder piles up at the end and often exceeds the 4-inch limit. Even spacing distributes the leftover so every gap stays uniform and code-compliant.

Do stairs follow the same rule?

Stair guards have their own allowances in the IRC: a 4-3/8 inch sphere on the open side of stairs. So set the maximum gap input to your local rule. The calculator adjusts the count and spacing based on the value you enter, keeping your stair layout within the correct limit.

Does the count include the posts?

No. The run is measured between the inside faces of the posts, and the posts close the two ends. The calculator returns only the number of balusters needed to fill that open span. Posts are structural supports at each end, not part of the infill count the tool produces.

What baluster width should I enter?

Enter the actual face width of the baluster at its widest point. That is 1.5 inches for a typical turned wood baluster, less for slim metal ones. The calculator subtracts this width from each gap to find the clear opening, so using the true widest measurement keeps your spacing accurate and compliant.

Sources

Related calculators

Stair Calculator
Riser count, exact riser height, tread count, total run and stair angle from your floor-to-floor height — checked against the 7¾-inch code cap.
Deck Board Calculator
How many deck boards a deck takes at your board width and gap — the board count, the total linear feet to buy, and the width the boards actually cover.
Fence Picket Calculator
How many pickets a fence run takes at your picket width and gap — with a waste allowance, the coverage the pickets give and the total gap width.
Ramp Calculator
Ramp run, slope length, angle and grade for a given rise — at the ADA 1:12 maximum, a gentler 1:16 or 1:20, or your own ratio.