π‘ Deck Baluster Spacing Calculator
Evenly spaced balusters with every gap under the 4-inch code limit.
Balusters Needed
For planning only. Confirm guardrail requirements with your local building code before you build.
How to Use This Calculator
Measure the clear distance between your posts in inches and enter your baluster width (a standard 2x2 baluster is 1.5 inches wide). The calculator finds the smallest number of balusters that keeps every gap at or under your maximum, then distributes the leftover space evenly so all gaps are identical.
Measure between the inside faces of the two posts. Measure at the height where the balusters will sit, since posts can lean slightly.
Enter the actual width of your balusters. For turned or shaped balusters, measure the widest point, since the gap is measured at the narrowest opening.
Leave the maximum gap at 4 inches for code compliance, or lower it to 3.75 for a safety margin against layout error.
Use the center-to-center spacing to lay out the rail: find the center, then mark outward in both directions for a perfectly symmetrical run.
The Baluster Spacing Formula
The formula solves for n, the number of balusters, by assuming every gap is exactly at the maximum G. Since you cannot install a fraction of a baluster, it rounds up, which pulls every real gap slightly under the maximum. Then it redistributes: total gap space is the railing length minus the balusters, divided equally across the n + 1 gaps (one gap at each end plus one between every pair of balusters).
The end gaps matter as much as the middle ones. A layout that spaces balusters evenly but leaves a wide gap against one post still fails the 4-inch rule and looks sloppy. Because this method treats the two end spaces as gaps in the same count, every opening, including the ones against the posts, comes out identical.
Worked Example
A 93-inch railing with 1.5-inch balusters and a 4-inch maximum gap. n = ceil((93 - 4) / (1.5 + 4)) = ceil(89 / 5.5) = ceil(16.18) = 17 balusters. Actual gap = (93 - 17 x 1.5) / 18 = (93 - 25.5) / 18 = 67.5 / 18 = 3.75 inches. Center-to-center spacing = 3.75 + 1.5 = 5.25 inches. Every gap is 3.75 inches, comfortably under the 4-inch code limit.
Tighten the maximum to 3.75 for extra margin: n = ceil((93 - 3.75) / 5.25) = ceil(17.0) = 17 balusters, giving gaps of exactly 3.75 inches. Try a 72-inch section instead: n = ceil((72 - 4) / 5.5) = ceil(12.36) = 13 balusters with gaps of (72 - 19.5) / 14 = 3.75 inches.
Tips for a Clean Install
Cut a spacer block to your exact gap width and use it to set every baluster. A physical spacer is faster and more consistent than measuring each gap, and it guarantees the layout matches your calculation. Clamp the baluster, set the spacer against it, position the next baluster, and fasten.
Keep the bottom of the balusters at a consistent height above the deck. Many codes also limit the opening under the bottom rail to 4 inches. And if your railing is long, consider splitting it with a mid post: shorter spans look better, the spacing math stays simple, and the rail is much stiffer.
Frequently Asked Questions
What is the 4-inch baluster rule?
Most US building codes require that a 4-inch sphere cannot pass through any opening in a guardrail, including the gaps between balusters. That means every gap between balusters must be under 4 inches. Inspectors check this with an actual 4-inch ball, so keep your gaps at 3.75 inches or less to have a margin for slight layout error.
Do I measure between the posts or the full railing length?
Measure between the faces of the posts, which is the clear span the balusters must fill. Enter that number as the railing length. If your railing runs post to post, that clear distance is what the calculator uses to distribute balusters evenly.
How do I mark the layout on the rail?
Work from the center outward so the two end gaps are equal. Find the center of the rail, then use your computed center-to-center spacing to mark each baluster position on both sides of center. Marking from center guarantees symmetry, which looks far better than a run that ends with a wide gap at one post.
Is stair baluster spacing different?
Yes. On stairs the balusters sit on a slope, so the horizontal gap effectively widens as the rail rises. Many codes tighten the limit on stairs to about 4 and 3/8 inches measured differently, and the triangle formed by the tread, riser, and bottom rail has its own rule (no 6-inch sphere). Check your local code before laying out stair balusters.
Can I use fewer, wider balusters to save money?
You can, but the math works against you: wider balusters mean fewer gaps, and each gap must still stay under 4 inches. The calculator shows you the minimum count that keeps gaps compliant. Skipping balusters to save a few dollars is the most common reason railings fail inspection.