Under the baluster spacing code used in most of the US, the gaps in a deck, porch or stair guard must be small enough that a 4 inch sphere cannot pass through. In practice, that means keeping every gap between balusters under 4 in. Most builders aim for about 3½ to 3⅞ in. The fastest way to get equal, code-safe gaps is our free baluster spacing calculator: enter the space between posts and the baluster width, and it tells you how many balusters to install and the exact gap.
This guide sums up the rules in the International Residential Code (IRC), the model code most US states and cities adopt for houses. Your local version may differ, so always confirm with your building department before you build.
The 4 Inch Rule for Balusters
IRC section R312.1.3 says that the required guards on decks, porches, balconies and raised floors must not have openings that allow a 4 in diameter sphere to pass through, from the walking surface up to the required guard height. The rule exists because a young child's head is about that size. A gap under 4 in keeps a child from slipping through, or getting their head stuck.
The rule is about clear openings, not the center-to-center distance. A 1½ in baluster set 5 in on center leaves a 3½ in gap, which passes. The same 5 in spacing with a thinner baluster could fail.
Two exceptions on stairs
- Open sides of stairs: guards on the open side of a stair may have openings that do not allow a 4⅜ in sphere to pass.
- The stair triangle: the triangle formed by the riser, the tread and the bottom rail of the guard may not allow a 6 in sphere to pass.
Many builders simply keep every gap under 4 in, stairs included. One rule everywhere means less to check and no surprises at inspection.

Quick Reference: Guard and Railing Code (IRC)
| Item | Residential requirement (IRC) |
|---|---|
| When a guard is required | On open sides of walking surfaces more than 30 in above the floor or grade below, measured within 36 in horizontally of the edge |
| Minimum guard height (decks, porches, balconies) | 36 in above the walking surface |
| Minimum guard height on open sides of stairs | 34 in, measured from a line connecting the stair nosings |
| Openings in the guard | A 4 in sphere must not pass |
| Openings on open sides of stairs | A 4⅜ in sphere must not pass |
| Stair triangle (riser, tread, bottom rail) | A 6 in sphere must not pass |
| Handrail height on stairs | 34 to 38 in, measured from the nosings |
| Guard load | Resist a 200 lb concentrated load at the top |
| Balusters and infill | Resist a 50 lb load applied over 1 ft² |
Commercial buildings follow the International Building Code (IBC), which generally requires 42 in guards. Some states and cities also adopt stricter residential rules, such as 42 in guards on higher decks. Check your local code.

How to Calculate Baluster Spacing
The goal is the same gap everywhere, including the gaps next to each post. Here is the method the calculator uses.
- Measure the clear space between posts in inches (L). Measure at the rail height, post face to post face.
- Note the baluster width (B). A 2 × 2 baluster is actually 1½ in wide.
- Choose a maximum gap (G) under 4 in. 3⅞ in is a common target.
- Number of balusters = (L − G) ÷ (B + G), rounded up to a whole number.
- Actual gap = (L − number × B) ÷ (number + 1).
Example: 72 in between posts, 1½ in balusters, 3⅞ in maximum gap. (72 − 3.875) ÷ (1.5 + 3.875) = 12.67, rounded up to 13 balusters. The actual gap is (72 − 13 × 1.5) ÷ 14 = 3.75 in, or 3¾ in, which is safely under 4 in. Each baluster then sits 5.25 in on center.
Always round the count up, never down. Rounding down makes every gap bigger, and it can push them over 4 in.
Common Baluster Spacing Examples
| Space between posts | Baluster width | Balusters (3⅞ in max gap) | Actual gap |
|---|---|---|---|
| 36 in | 1½ in | 6 | 3.86 in |
| 48 in | 1½ in | 9 | 3.45 in |
| 60 in | 1½ in | 11 | 3.62 in |
| 72 in | 1½ in | 13 | 3.75 in |
| 96 in | 1½ in | 18 | 3.63 in |
| 72 in | ¾ in (metal) | 15 | 3.80 in |
Tips for a Railing That Passes Inspection
- Use a spacer block. Cut a scrap to the exact gap and use it between every pair of balusters, so small errors do not add up along the run.
- Start from the middle on long runs if you want a baluster or a gap centered on a feature, and work out toward both posts.
- Check the bottom gap. The 4 in rule applies from the deck surface up. Keep the bottom rail low enough that a 4 in sphere cannot pass under it.
- Allow for wood movement. Wet pressure-treated balusters shrink as they dry. A 3¾ in gap can open up toward 4 in, so leave some room.
- Do not forget the posts. Guard posts must be attached well enough to resist the 200 lb load at the top. Through-bolts or tested hardware connectors are the usual way.
- Horizontal rails and cable: cable must stay tight enough that a 4 in sphere cannot be pushed through between the cables, and some areas restrict horizontal infill that children can climb. Ask your inspector.
Planning the rest of the deck? Our fence and deck calculators cover deck boards, screws and stain, and the guide to stair rise and run code covers the steps.
Frequently Asked Questions
What is the maximum baluster spacing allowed by code?
Under the IRC, the clear opening between balusters must not let a 4 in sphere pass through. That means every gap must be less than 4 in. On the open side of stairs, the limit is a 4⅜ in sphere.
Is baluster spacing measured center to center?
No. The code limits the clear gap between balusters, not the on-center distance. Measure from the face of one baluster to the face of the next.
How many balusters do I need per foot?
With 1½ in balusters and gaps under 4 in, you need about 2.2 to 2.3 balusters per foot of railing. A 6 ft section usually takes 13 balusters.
When is a deck railing required?
The IRC requires a guard where the walking surface is more than 30 in above the floor or ground below, measured within 36 in of the edge. Many owners add a railing on lower decks for safety anyway.
How tall does a deck railing have to be?
At least 36 in above the deck surface under the IRC. Commercial buildings, and some local codes, require 42 in.
Does the 4 inch rule apply to the gap under the bottom rail?
Yes. The rule covers the whole guard from the walking surface up to the required height, so the space under the bottom rail must not let a 4 in sphere through either.
Code references: 2021 International Residential Code sections R312.1 (guards), R311.7.8 (handrails) and Table R301.5 (loads). Adopted codes vary by state and city.