Balusters exist to keep a small child's head from passing through a guard, which is why the IRC writes the rule as a sphere: a 4" ball must not pass any opening in a level guard, and a 4-3/8" ball must not pass the open side of a stair. Spacing them is simple arithmetic, but it has to come out even at both posts, and on a stair rail every mark stretches with the slope. 72" between posts takes 13 wood balusters at 3-3/4" or 16 metal ones at 3-1/2".
The sphere rules
IRC R312.1.3: openings in a required guard must stop a 4" sphere. On the open sides of a stair the limit is 4-3/8", and the triangle formed by a riser, a tread and the bottom rail may be as big as a 6" sphere. The gap between the deck and the bottom rail counts too: keep it under 4".
Guards are required where the walking surface is more than 30" above the grade below; on stairs, DCA 6 shows a guard once the total rise reaches 30". Guard height is 36" at a level deck and 34" above the nosings on a stair.
Centred layout: equal gaps at both posts
Pick the largest gap you will accept (3-3/4" leaves a 1/4" margin under the sphere). The number of balusters is the smallest count that keeps every gap at or under it; the gaps are then whatever divides the space evenly, including the two against the posts.
For 72" between posts and 1-1/2" balusters: 13 balusters, 14 gaps of 3-3/4". Hook the tape on the post: the first edge goes at 3-3/4", the next at 9", then every 5-1/4".
n = ⌈ (L − g) ÷ (w + g) ⌉ gap = (L − n × w) ÷ (n + 1) mark k = gap + (k − 1)(w + gap)
Start-from-post layout
Some railing systems and many builders start at one post with a fixed gap and let the remainder fall at the far post. It is quicker to mark, but the last gap can come out wide enough to fail. The calculator shows that remainder and fails the sphere check when it is too big; switch to the centred layout to fix it.
Sloped stair rails: divide by cos θ
Plumb balusters on a stair are still spaced horizontally: the sphere is pushed straight through the guard, so the gap that counts is the level one between two balusters. Your tape, though, runs along the sloped rail. Every level distance becomes longer by 1 ÷ cos θ, where θ is the stair angle.
On a 7-1/2" × 10" stair (36.9°) that factor is 1.2500: a 5-1/4" level spacing is 6-9/16" along the rail, and every fillet strip between balusters is cut to the along-rail gap with the rake angle on both ends.
Keep the bottom rail close to the nosings: on that stair, more than 1-1/2" above the nosing line lets a 6" sphere through the triangle.
along the rail = level distance ÷ cos θ θ = atan(rise ÷ run)
Open treads: two or three per tread
With balusters fixed to the treads, the spacing is the tread depth divided by the count. Two 1-1/2" balusters per 10" tread leave 3-1/2" gaps; two 3/4" metal balusters per tread pass only on treads up to 10-1/4". Three per tread passes on any common tread.
Each baluster further back on a tread sits higher under the rail: the second is longer than the first by the rise divided by the count.
Posts and buying
DCA 6 limits guard posts to 6'-0" apart; on 4x4 posts that is 68-1/2" clear. Aluminium and composite railing kits are often tested for 6 ft or 8 ft sections under their own evaluation reports, so follow the kit. Buy about 10% extra balusters for splits, knots and miscuts.