Deck Railing & Baluster Spacing Calculator

Use this deck railing spacing calculator to figure out exactly how many balusters you need and what gap spacing keeps your deck rail code-compliant — no guesswork, no gaps over 4 inches.

Opening: 72 in Baluster width: 1.5 in Gap: 3.75 in On-center: 5.25 in
Please enter a span greater than 0.
Enter a baluster width greater than 0.
Enter a max gap greater than 0.
Enter at least 1 section.

Estimates only. By using this calculator you agree to our Terms.

How to Use This Deck Railing Spacing Calculator

Enter the clear opening width between your posts (the horizontal span where balusters will go), the width of the baluster you plan to use, and the maximum gap your local code allows — typically 4 inches so a 4-inch sphere can't pass through. Add the number of equal post-to-post sections if you're calculating a full railing run. Click Calculate Spacing to get the exact number of balusters, the actual gap between them, and the on-center spacing to mark on your rail.

Why This Matters

Building code (IRC R312.1.3 in most U.S. jurisdictions) requires that guardrail openings not allow a 4-inch sphere to pass through, which protects small children from slipping through or getting stuck. Contractors and DIYers building a deck railing need to know exactly how many balusters to buy and where to mark them so the finished gaps are equal and under 4 inches — uneven spacing looks unprofessional and can fail inspection. This calculator is useful whether you're framing a 6-foot section between two 4x4 posts, a curved deck with several shorter runs, or a full 40-foot railing with a dozen sections. Instead of eyeballing spacing or doing the math by hand for every section, plug in your numbers once and get a precise baluster count and marking spacing that passes inspection the first time and looks evenly spaced from every angle.

How It's Calculated

The calculator finds the smallest number of balusters that keeps the gap between them at or under your maximum allowed gap. The formula:

n = ceil( (Span − MaxGap) / (BalusterWidth + MaxGap) )

Where n is the number of balusters per section. Once n is found, the actual gap is recalculated so every gap is equal:

Actual Gap = (Span − n × BalusterWidth) / (n + 1)

On-center spacing (baluster centerline to centerline, useful for marking your rail with a tape measure) is simply Actual Gap + Baluster Width. This method guarantees the fewest balusters possible while staying compliant, and it distributes the leftover space evenly across every gap instead of leaving one odd gap at the end.

Worked Example

Say you have a 72-inch opening between two posts, you're using 1.5-inch square balusters, and your code max gap is 4 inches.

n = ceil( (72 − 4) / (1.5 + 4) ) = ceil( 68 / 5.5 ) = ceil(12.36) = 13 balusters

Actual Gap = (72 − 13 × 1.5) / (13 + 1) = (72 − 19.5) / 14 = 52.5 / 14 = 3.75 inches

On-center spacing = 3.75 + 1.5 = 5.25 inches. That's exactly what the calculator returns by default — 13 balusters, a 3.75-inch gap (under the 4-inch max), and 5.25 inches on-center for marking your layout.

Tips & Common Mistakes

Frequently Asked Questions

What is the maximum gap allowed between deck balusters?

Most U.S. jurisdictions following the IRC require gaps small enough that a 4-inch sphere cannot pass through the railing. Always confirm the exact number with your local building department, since some areas require tighter spacing.

How do I measure the opening width for baluster spacing?

Measure the clear horizontal distance between the inside faces of your two end posts (not post center to post center). This is the actual space your balusters and gaps need to fill.

Should baluster spacing be measured on-center or as a gap?

Building code measures the gap (open space) between balusters, but installers usually mark layout using on-center spacing since it's easier to measure with a tape from centerline to centerline of each baluster.

Can I use this calculator for stair railings?

Yes — stair guard baluster spacing follows the same 4-inch sphere rule horizontally, though some codes allow a slightly larger triangular opening at the stair nosing. Enter your stair section span the same way as a level railing.

What baluster width should I use for round balusters?

Enter the diameter of the round baluster as the "baluster width" — the calculator treats it the same as a square baluster's face width for spacing purposes.

Why does the calculator round up the number of balusters?

Rounding up guarantees the resulting gap never exceeds your maximum allowed spacing. Rounding down would produce a gap larger than code allows, which could fail inspection.

Related Tools