Baluster spacing calculator

Enter your railing's total length, baluster width, and the maximum code-allowed gap to get an exact baluster count and evenly split spacing.

Rail run length
ft
Baluster width
in
Max gap allowedi
in
Result
Balusters needed17
Actual gap3.92 in

Estimate only — check your local code's exact max-gap requirement before building.

How baluster spacing is calculated

We solve for the smallest baluster count where n balusters plus (n+1) gaps fit the rail length without any gap exceeding your max — n = the ceiling of (length − max gap) ÷ (baluster width + max gap) — then recompute the actual gap as (length − n × baluster width) ÷ (n + 1), splitting the leftover space evenly across every gap from end to end.

Codes cap the gap — commonly under 4 in, sized so a 4 in sphere can't pass through — to keep young children from squeezing through the railing or getting a head caught between balusters. Rounding the baluster count up and re-splitting the leftover space evenly keeps every single gap at or under that limit, rather than crowding one end and leaving slack at the other; inspectors measure the actual built gap, not the target number on a plan.

Frequently asked questions

Most US residential codes require gaps small enough that a 4 in sphere can't pass through — check your local building department, since some jurisdictions use a stricter standard.

Real-world railings rarely divide evenly into whole 4 in gaps, and inspectors check the actual built gap — spacing slightly under 4 in and splitting evenly avoids failing inspection over a fraction of an inch.