Railing Calculator
Railing Calculator
A safe, good-looking railing needs evenly spaced balusters that also satisfy the building code's "4-inch sphere rule" — the gap between balusters (and between baluster and post) must not allow a 4 in sphere to pass. Our Railing Calculator estimates how many balusters fit a given rail length and what the actual spacing will be after you account for baluster width. It helps deck and stair builders plan cuts and spacing before installing.
Why Spacing Matters
The 4 in sphere rule (IRC) prevents small children from getting their heads stuck. Balusters wider than the gap reduce the count but also reduce the opening, so spacing must be checked after accounting for baluster width.
What Affects the Count?
The count depends on the rail length, the baluster width, and the target spacing. Wider balusters or tighter spacing reduce the number that fit; the calculator reports the actual resulting gap so you can verify code compliance.
The 4-inch sphere rule in practice
The rule comes from the IRC guarding section: a 4 in diameter sphere must not pass through any opening in the guard. That includes the gap between two balusters and the gap between an end baluster and the post. Because the baluster itself takes up width, the visible gap is smaller than your "target spacing." The calculator subtracts baluster width from the rail so the reported actual gap is the true opening you would measure on site — the number an inspector checks.
- Enter the Rail Length in inches (measure between the posts).
- Enter the Baluster Width in inches (default 1.5 in).
- Enter the Target Spacing in inches (default 4 in).
- Click Calculate for baluster count, actual spacing, and end newel posts.
Worked Example 1: A 120 in Rail, 1.5 in Balusters, 4 in Spacing
Pitch = 4 + 1.5 = 5.5 in. Count = floor((120 + 4) / 5.5) = floor(124 / 5.5) = floor(22.5) = 22 balusters. Actual spacing = (120 − 22 × 1.5) / 23 = (120 − 33) / 23 = 87 / 23 ≈ 3.78 in. Under 4 in, code-compliant.
Worked Example 2: A 72 in Rail
Pitch = 5.5. Count = floor((72 + 4) / 5.5) = floor(13.8) = 13. Actual spacing = (72 − 19.5) / 14 = 52.5 / 14 ≈ 3.75 in.
Edge Cases
- Zero length → no result.
- Very tight spacing → more balusters, smaller gaps.
- Wide balusters → fewer balusters, but gaps may still need checking.
- End posts: this estimates 2 newel posts at the ends; add posts at turns separately.
- Stair rails → use the sloped run length, not the horizontal.
- Non-4 in target → the calculator shows the actual gap so you can verify.
Worked Example 3: A 96 in Rail, 2 in Balusters, 4 in Spacing
Pitch = 2 + 4 = 6. Count = floor((96 + 4)/6) = floor(16.67) = 16. Actual gap = (96 − 16×2)/17 = 64/17 ≈ 3.76 in. Code-compliant, with wider balusters still under 4 in.
Worked Example 4: A 144 in Rail at 3 in Target
Pitch = 1.5 + 3 = 4.5. Count = floor((144 + 3)/4.5) = floor(32.67) = 32. Actual gap = (144 − 32×1.5)/33 = 96/33 ≈ 2.91 in. Tighter target yields a much smaller gap — more balusters, more labor.
Stair balusters
On stairs, balusters are usually plumb (vertical) while the rail slopes, so the run between posts is the sloped length. Use that length, not the horizontal, or the count will come up short on a steep run.
Worked Example 5: A 180 in Deck Rail, 1.25 in Balusters
Pitch = 1.25 + 4 = 5.25. Count = floor((180 + 4) / 5.25) = floor(35.05) = 35. Actual gap = (180 − 35 × 1.25) / 36 = (180 − 43.75) / 36 = 136.25 / 36 ≈ 3.79 in. A 180 in rail needs noticeably more balusters than a 120 in rail but holds the same sub-4 in gap.
Worked Example 6: A 60 in Rail at 3.5 in Target
Pitch = 1.5 + 3.5 = 5. Count = floor((60 + 3.5) / 5) = floor(12.7) = 12. Actual gap = (60 − 12 × 1.5) / 13 = 42 / 13 ≈ 3.23 in. Aiming for 3.5 in leaves a comfortable margin under the 4 in rule even after width is subtracted.
Bottom rail and the sphere rule
Some codes apply the 4 in sphere rule to the opening between the bottom rail and the deck floor, not just between balusters. If your bottom rail sits 4 in above the floor, that gap must also be checked; a lower bottom rail or a kick plate closes it. The baluster spacing alone does not satisfy that check.
Total rail-board length
Beyond balusters, budget top and bottom rail boards equal to the run length (plus post overlap). A 120 in run needs at least 120 in of top rail and 120 in of bottom rail, often in two pieces with a scarf joint at a post. The calculator returns balusters; add the rails from the total length.
The repeating pitch is baluster width Wb plus target spacing s:
Number of balusters that fit a rail of length L:
The actual spacing once N balusters are placed (with N+1 gaps):
Balusters for a 120 in rail (1.5 in balusters) at various target spacings:
| Target Spacing (in) | Balusters | Actual Gap (in) |
|---|---|---|
| 3 | 27 | 2.77 |
| 4 | 22 | 3.78 |
| 5 | 18 | 4.83 |
| 6 | 16 | 5.81 |
| 8 | 12 | 7.83 |
Tighter target spacing fits more balusters but yields a smaller actual gap.
Balusters for various rail lengths (1.5 in balusters, 4 in target):
| Rail Length (in) | Balusters | Actual Gap (in) |
|---|---|---|
| 48 | 9 | 3.79 |
| 72 | 13 | 3.75 |
| 96 | 18 | 3.83 |
| 120 | 22 | 3.78 |
| 144 | 27 | 3.72 |
Longer rails fit proportionally more balusters while holding the gap near the target.
Actual gap vs baluster width (120 in rail, 4 in target):
| Baluster Width (in) | Balusters | Actual Gap (in) |
|---|---|---|
| 1.0 | 24 | 3.83 |
| 1.5 | 22 | 3.78 |
| 2.0 | 21 | 3.71 |
| 2.5 | 19 | 3.75 |
| 3.0 | 18 | 3.67 |
Wider balusters slightly reduce count but keep gaps under 4 in.
Balusters for a 72 in rail (1.5 in balusters) at various targets:
| Target Spacing (in) | Balusters | Actual Gap (in) |
|---|---|---|
| 3 | 17 | 2.72 |
| 4 | 13 | 3.75 |
| 5 | 11 | 4.75 |
| 6 | 9 | 5.75 |
| 8 | 7 | 7.75 |
The 5 in target already exceeds the 4 in rule, so stay at 4 in or below for guards.
- Verify the 4 in rule: the actual gap must be under 4 in after width is included.
- Add newel posts: count 2 per straight run; more at corners and turns.
- Use a spacing jig: a custom block keeps gaps even during install.
- Round spacing visually: small gaps read as uniform if cut consistently.
- Check local code: some areas require closer spacing or specific heights.
- Measure between posts: use the clear span, not the overall rail.
- Straight runs only: stairs and curves need sectional work.
- Two end posts assumed: does not count intermediate posts.
- Uniform balusters: assumes identical width throughout.
- No rail height: checks spacing only, not guard height.
- Approximate gap: real install varies with cutting.
- US units: inches.
How many balusters for a 120 in rail?
With 1.5 in balusters and 4 in spacing, about 22 balusters, giving a 3.78 in actual gap.
What is the 4 inch sphere rule?
The gap between balusters (and to posts) must not pass a 4 in sphere, a common US guardrail code.
Does baluster width affect spacing?
Yes. Wider balusters take more room, so the actual gap shrinks after they are placed.
How many newel posts do I need?
This calculator assumes 2 at the ends of a straight run; add more for corners and direction changes.
Can I use this for stairs?
Yes, but enter the sloped rail length, not the horizontal run.
Why does the actual spacing differ from target?
The fixed baluster width shifts the even gaps slightly; the calculator reports the real value.
What if my gap exceeds 4 inches?
Reduce the target spacing or widen balusters until the actual gap is under 4 in.
Should spacing be exactly 4 inches?
No — it must be 4 in or less; aim slightly under to be safely compliant.
Do I count the posts as balusters?
No. Posts are separate; this estimates balusters between the end posts.
Is rail height included?
No. Check your local minimum guard height separately from spacing.
What is the minimum guard height?
Most US residential decks require a 36 in guard above the floor; commercial and some local codes require 42 in. Height is a separate check from baluster spacing.
Should I space at exactly 4 inches?
No — aim slightly under, around 3.5–3.75 in, so minor cutting or shrinkage never pushes a gap over 4 in.
How many newel posts for an L-shaped rail?
Two at the start and two at the turn (or a 3-post corner), plus two at the end. The calculator assumes a straight run; add posts at every direction change.
Do I count the top and bottom rails?
This tool estimates balusters only. Budget separate top and bottom rail boards by the total run length, plus posts.
What about cable or glass rails?
Cable and glass systems use different spacing rules (cable must not allow a 4 in sphere between cables). Use a dedicated cable calculator or the post spacing for those systems.
Can I use this for interior stairs?
Yes, as long as you enter the sloped rail length and meet the local guard height for the location.
How do I verify compliance on site?
After install, pass a 4 in sphere (a ping-pong or practice ball of that diameter) through every gap. If it passes anywhere, tighten the spacing or widen balusters on the next section. The calculator's actual-gap figure is the planning number; the ball test is the field check.
Should balusters be centered or flush to posts?
Center the first and last baluster in the clear span so the end gaps to the posts match the interior gaps. If you push balusters flush to a post, that end gap may exceed 4 in and fail. Use the post-to-post clear length, not the overall rail, as the input.
Can I mix baluster widths in one rail?
Not safely without rechecking every gap. The formula assumes one width; mixing 1.5 in and 2 in balusters changes the pitch mid-rail and can open a gap. Keep one width per run, or compute each segment separately.
How many balusters for a wrap-around porch?
A wrap has multiple straight runs meeting at corner newels. Compute each run with the calculator, sum the balusters, and add a newel at every inside and outside corner. The total is the sum of the straight-run counts plus the corner posts.
Does baluster spacing change with guard height?
No — spacing (the 4 in gap) is independent of guard height (36 in residential, 42 in commercial). Both are code checks, but the calculator handles spacing only; confirm height separately with your local authority.
Last updated: July 18, 2026
UnByte — Independent Software Engineering
Every calculator references authoritative sources — Editorial policy