Count equal spaces, including both ends
Let L be the clear distance between the inside faces of the end posts, b the baluster width, and g the maximum permitted clear gap supplied by the user. With n balusters there are n + 1 clear spaces, because the two end spaces count as well as every interior gap. The calculator chooses the smallest nonnegative whole n for which (L − n × b)/(n + 1) is no greater than g. This keeps the remaining spaces equal under the model.
The count calculation is n = max[0, ceil((L − g)/(b + g))]. After choosing n, the resulting equal gap is (L − n × b)/(n + 1). Measure the opening between the actual end constraints, use the installed baluster width rather than a nominal label if it differs, and keep all lengths in millimetres. If the geometry produces a negative remaining gap, the selected balusters physically do not fit the opening.
Worked examples
Fourteen balusters across a 2,000-mm opening
Inputs: Clear opening = 2,000 mm; baluster width = 40 mm; maximum clear gap = 100 mm
Calculation: n = ceil((2,000 − 100)/(40 + 100)) = 14; gap = (2,000 − 14×40)/(14 + 1) = 1,440/15
Use 14 balusters for an equal modeled clear gap of 96 mm.
Twelve balusters with 35-mm width
Inputs: Clear opening = 1,540 mm; baluster width = 35 mm; maximum clear gap = 95 mm
Calculation: n = ceil((1,540 − 95)/(35 + 95)) = 12; gap = (1,540 − 12×35)/(12 + 1) = 1,120/13
The model returns 12 balusters and 86.1538 mm equal clear gaps.
Example: choose a count for a 2-m rail opening
For L = 2,000 mm, b = 40 mm, and maximum gap g = 100 mm, the count threshold is (2,000 − 100)/(40 + 100) = 1,900/140 = 13.5714. Rounding up gives 14 balusters. Their total width is 14 × 40 = 560 mm, leaving 1,440 mm for 15 equal spaces. Each clear space is 1,440/15 = 96 mm, which is below the entered 100 mm limit.
Using 13 balusters would leave 2,000 − 520 = 1,480 mm over 14 spaces, or about 105.714 mm per gap, which exceeds the input limit. The ceiling step is therefore necessary: rounding to the nearest integer could select a count that violates the chosen spacing.
Example: repeat the calculation with a narrower rail
Suppose the clear opening is 1,540 mm, each baluster is 35 mm wide, and the maximum clear gap is 95 mm. The threshold is (1,540 − 95)/(35 + 95) = 1,445/130 = 11.1154, so use 12 balusters. Their combined width is 420 mm; the 1,120 mm remainder divided among 13 spaces gives 86.1538 mm per equal gap.
A wider baluster changes both the number of spaces that can fit and the amount of opening consumed by solid material. Recalculate from actual dimensions when the product changes. The result does not lay out screw positions, account for tapered or irregular openings, or verify that balusters and rails can resist structural loads.
Keep geometry separate from code compliance
Building codes and safety rules depend on the adopted jurisdiction, building type, location, height, and applicable exceptions. For example, the 2021 International Residential Code contains opening-limit provisions for required guards, including a sphere test in specified contexts. That reference is not a universal specification for every rail, and this calculator does not select a code limit or test the whole assembly. Set the maximum gap only after checking the requirements that apply to the project.
A gap measurement also does not address rail strength, attachment, material condition, load resistance, climbing hazards, or inspection requirements. Treat the output as a count-and-spacing layout aid. If the project is regulated or the rail protects a fall edge, have the dimensions and complete installation checked against the locally adopted requirements by a qualified person.
Check the layout at both ends before fastening
Mark the inside faces of the end posts and confirm the clear opening across the rail. Use a story pole or spacing jig to transfer the equal gap along the full span, then verify the first and last spaces against the same dimension. Measuring only between baluster centerlines can miss the clear edge gaps, which is why the calculator divides the remaining length into n + 1 spaces.
If an opening is not parallel or baluster widths vary, equal gaps measured along one reference line may not stay equal at every height. The formula assumes a straight opening and identical vertical balusters of constant width. Verify actual fit with the chosen parts before cutting multiple pieces, and do not use the numerical result as evidence of structural or regulatory approval.