How do I work out the number of balusters and the even gap?
Three numbers go in: the rail length between the posts, the width of one baluster and the biggest gap you will allow. Four come out.
- Balusters, N = (rail − biggest gap) ÷ (baluster width + biggest gap), rounded up. Round up, never down: rounding down leaves a gap wider than your limit.
- Even gap = (rail − N × baluster width) ÷ (N + 1). N balusters leave N + 1 gaps, because the gap next to each post counts.
- On-center spacing = even gap + baluster width. It is the distance from the middle of one baluster to the middle of the next.
- First baluster = the even gap from the post to its edge, or the even gap plus half the baluster width to its center.
Rail length is post to post, inside face to inside face: that is the opening the balusters fill. The calculator rounds only what it shows, to the nearest 1/16", and it works every mark out exactly first, so the rounding does not add up along the rail.
A worked example: a 9' 4-1/2" rail
The rail is 9' 4-1/2", which is 112-1/2" or 112.5". The balusters are 1-1/2" wide and the biggest gap is 4".
| Step | The sum | Result |
|---|---|---|
| Balusters | (112.5 − 4) ÷ (1.5 + 4) = 108.5 ÷ 5.5 = 19.73, rounded up | 20 |
| Even gap | (112.5 − 20 × 1.5) ÷ 21 = 82.5 ÷ 21 = 3.9286" | 3-15/16" |
| On center | 3.9286 + 1.5 = 5.4286" | 5-7/16" |
| First baluster | edge at 3-15/16" from the post; center at 3.9286 + 0.75 = 4.6786" | 4-11/16" |
Check it by adding up: 20 × 1.5" of balusters + 21 × 3.9286" of gaps = 30" + 82.5" = 112.5". The gaps and the balusters fill the rail exactly, and every gap is under 4".
The list in the calculator above carries this example: the first baluster centers at 4-11/16", the second at 10-1/8" and the third at 1' 3-9/16". Replace the numbers with yours and the list follows.
The layout list: every mark from the left post
The table under the calculator gives the left edge, the center and the right edge of every baluster, measured from the inside face of the left post. Hook the tape on the post and mark the center of each baluster, or the left edge if you set a spacer block against it. The right post sits at the rail length, so the last gap closes on it. Check that last mark against the post before you fasten anything: if the post is 1/8" out, the rail you measured was.
The full list is on the page already. If you want it on paper at the rail, press Email me the layout sheet (PDF) and it comes to your inbox as one US Letter page with your rail, your answer, the marks and the sums; or press Print the layout and your browser prints the same list.
The rule behind “4 inches”
The 4" is not a rule of thumb. In the 2021 International Residential Code (as Colorado adopted it) it is R312.1.3, Opening Limitations: required guards shall not have openings, from the walking surface up to the required guard height, that allow passage of a sphere 4 inches in diameter. The test is a sphere, so it is the clear opening you measure, not the on-center spacing. The “gap” in this calculator is the clear space between two balusters, or between a baluster and a post.
Three more things the same section says:
- The triangle at the tread. On a stair, the triangular opening formed by the riser, the tread and the bottom rail of the guard may not pass a 6" sphere (exception 1).
- The open side of a stair. Guards on the open side of stairs may not have openings that pass a 4-3/8" sphere (exception 2). So a stair is a different number from a deck.
- Height. Required guards are at least 36" high, measured above the walking surface or the line through the nosings (R312.1.2). On the open side of a stair the minimum is 34", measured from the nosing line.
And the limits of what this page can tell you: that is the model code, read in the 2021 edition as Colorado adopted it, and the 2024 Residential Code of New York State repeats it as R321.1.3. States and towns adopt different editions and amend them, so your local code decides. The calculator starts at 4" because that is the model code’s number. If your inspector gives you another, type it in the third box. If you type more than 4", the calculator warns you.
Deck, stair or interior?
The code text above does not split decks from interior rails: it speaks of “required guards” at open-sided walking surfaces, “including floors, stairs, ramps and landings” (R312.1.1), where the drop is more than 30" within 36" of the edge. So the 4" sphere applies to a deck guard and to an interior balcony or landing guard the same way. The stair has its own two numbers, 4-3/8" and 6".
The calculator lays out a level run: a deck rail, a landing, a balcony. For a stair rail, Angi says to measure the horizontal projection of the rail, not the diagonal length. That fits how balusters stand: they hang plumb, so the clear opening a sphere meets is the level distance between them. Type the horizontal projection as the rail, then mark the posts and the balusters plumb. We have not built a stair mode, so check each finished opening against the stair numbers above before you fasten. The stair’s own rise and run are on the stair calculator.
What do the other calculators leave out?
We read today’s results on 2026-11-18. Decks.com takes the baluster width and the space in 1/8" steps from a list, handles several sections and a staircase section, and says the same 4" figure; it gives the spacing and the center points, but not a sheet to print or the code section. Angi gives a table that counts 16 balusters for a 5' rail at 4", with 2" end spacing and no baluster width in the sum; with 1-1/2" balusters and a 4" gap, the same rail needs 11, and the table’s 16 would put the gaps near 2". h3apps.com is the page for an app, with no calculator on it. The top result is a Reddit thread. None of them lists the marks to 1/16" from a tape reading and prints them, and none sets the stair numbers beside the 4" rule.
Do it on your phone with the calculator app
The same sums run in Fraction Feet Inch Calculator, and the app does not have a baluster tool: the page does the baluster arithmetic, the app does the feet-inches-fractions arithmetic. Type the lines for the worked rail:
112-1/2" - 20 x 1-1/2"
÷ 21
The first line is the rail less the balusters, 82-1/2"; the second divides by the 21 gaps. The app adds, subtracts, multiplies and divides feet, inches and fractions exactly and answers to the nearest 1/16", so you get the even gap as a fraction at the rail with no signal needed: it works offline and keeps the history of every answer. Add the baluster width to the gap to get the on-center spacing.
People also ask
What is the recommended spacing for deck railing balusters?
No more than 4" between them, as the clear opening: that is the sphere test in the model code (IRC 2021 R312.1.3), and Decks.com says the same. On center that is about 5-1/2" for 1-1/2" balusters. Your local code decides.
How do I calculate stair spindles?
Use the same four steps on the stair rail’s horizontal projection, then check the finished openings: 4-3/8" at the open side of the stair and 6" at the triangle by the tread (R312.1.3, exceptions 2 and 1). The calculator above does the level-run arithmetic.
What is the code for stair baluster spacing?
In the 2021 IRC, guards on the open side of stairs may not have openings that pass a 4-3/8" sphere, the triangle at the tread and bottom rail may not pass a 6" sphere, and the guard is at least 34" high from the nosing line (R312.1.3 and R312.1.2). Local codes amend this.
How do I figure out the spacing between boards?
Subtract the boards’ total width from the opening and divide by one more than the number of boards: (opening − boards × board width) ÷ (boards + 1). It is the same even-gap sum as step 2 above, and works for slats and pickets too.