The short answer: a deck needs a guard where it is more than 30" above the ground. The guard must be at least 36" tall, and no opening in it may let a 4" ball through. Along the stairs the ball is 4 3/8" and the height is 34" above the nosings; in the triangle under the bottom rail, the ball is 6".
The numbers inspectors check
| Item | Model code | IRC section |
|---|---|---|
| When a guard is required | More than 30" above the floor or ground at any point within 36" of the edge | R321.1.12021: R312.1.1 |
| Guard height on a deck | 36" minimum from the deck boards | R321.1.22021: R312.1.2 |
| Guard height on stairs | 34" minimum from the line of the nosings | R321.1.22021: R312.1.2 |
| Openings on a deck | A 4" ball must not pass | R321.1.32021: R312.1.3 |
| Openings along stairs | A 4 3/8" ball must not pass | R321.1.3, exception 22021: R312.1.3 |
| Triangle under the bottom rail on stairs | A 6" ball must not pass | R321.1.3, exception 12021: R312.1.3 |
Your city or county adopts the code with its own changes, and some still use an older edition. The numbers above have not changed between the 2021 and 2024 editions; only the section numbers moved.
When a deck needs a railing
The trigger is height, not size. A guard is required on any open side of a deck, porch, balcony or landing that is more than 30" above the floor or ground below, at any point within 36" of the edge. The 36" part matters on a sloping yard: measure the drop 3 feet out from the edge, not right next to the deck.
Insect screening does not count as a guard. Below 30" the code does not ask for one, but a railing still makes sense around a hot tub, a step-down or a deck that small children use.
How tall the railing must be
- On the deck: 36" minimum, measured straight up from the top of the deck boards to the top of the guard. If a built-in bench sits against the railing, plan the rail taller: a child can stand on the seat, and the commercial code measures from it.
- On the stairs: 34" minimum, measured straight up from the line that connects the front edges of the treads. When the top of that guard is also the handrail, it must be between 34" and 38".
- 42" is not the IRC number. It comes from the commercial code (IBC), which covers apartments and businesses. Some cities use it for houses too, so check.
Baluster spacing: the 4" rule
The code does not give a spacing number. It gives a test: no opening in the guard may let a 4" ball pass, anywhere from the deck boards up to the required height. That covers the gaps between balusters, the gap between the last baluster and the post, and the space under the bottom rail.
- Every gap must be under 4". Exactly 4" is a fail in practice, and wood balusters shrink and bow after they are installed. Most builders work to about 3 1/2"; a 2x4 on edge makes a handy spacer.
- The clear gap is what counts, not the distance from center to center.
- Keep the gaps equal. Lay out each section from its own measurement so the gap at both posts matches the rest. The baluster spacing calculator does the math and gives you the marks.
Stair railings
Two things change on the open side of a stair.
The ball is 4 3/8"
The extra 3/8" lets a stair use two balusters per tread. Because balusters stand plumb, the gap is measured level, not along the slope of the rail. With 2x2 balusters, two per tread work on treads with a run under 11 3/4". With 3/4" metal balusters, two per tread only work on runs under 10 1/4", so most deck stairs need three.
The triangle under the bottom rail: 6"
Where a bottom rail runs above the treads, the riser, the tread and the rail form a triangle. That opening may be larger, but it must still stop a 6" ball. With the rail right on the line of the nosings, a 7 1/2" × 10 1/2" stair leaves room for a ball about 5 1/8" across, so it passes. Raise the rail and the opening grows: on that stair, the underside of the rail can sit no more than about 1 5/16" above the nosings. The calculator checks it for your stair.
How strong a guard must be
The IRC load table (Table R301.5) asks two things of a guard:
- The top of the guard must resist a 200-pound load pushed outward or downward at any point along it. Since the 2021 edition, the inward and upward load is 50 pounds.
- The balusters and other infill must resist 50 pounds pushed on one square foot.
Posts carry that load into the deck framing, and the code gives no single detail for how. The American Wood Council's deck guide, DCA 6, shows tested post connections with hardware that ties the post to the joists; a 4x4 bolted to the rim alone often loosens over time. Railing kits sold at Home Depot and Lowe's come with their own post spacing and mounting instructions, and following them is part of meeting the code.
Mistakes that fail inspection
- A wide gap at the posts. Starting the layout at one post and working across leaves whatever is left at the other end. Lay out from the center or use equal gaps.
- Measuring stair gaps along the rail. The level gap is the one that counts, and it is smaller than it looks along the slope.
- A tall gap under the bottom rail. On a deck, the space between the deck boards and the bottom rail must stop a 4" ball too.
- Using the nominal size. A 2x2 is 1 1/2" wide, not 2". A spacing worked out with 2" leaves gaps that are too wide.
- Forgetting the stairs. If the stair has 4 or more risers it needs a handrail, and if it is more than 30" high on an open side, it needs a guard too.
Questions people ask
How high does a deck railing have to be?
At least 36" under the International Residential Code, measured straight up from the deck boards. On the open side of the stairs it is at least 34", measured from the line of the tread nosings. Commercial buildings and some cities ask for 42", so check locally.
Do I need a railing if my deck is under 30 inches?
The code requires one only where the deck is more than 30" above the ground at any point within 36" of its edge. Measure where the yard slopes away: a deck that starts low can be over 30" a few feet out. Below that, a railing is optional, but many people still add one.
What is the 4-inch rule for balusters?
No opening in a required guard may let a ball 4" in diameter pass through, from the deck boards up to the required height. Inspectors check it with a 4" ball or a gauge. It is sized to keep a small child's head from getting through.
Can balusters be exactly 4 inches apart?
Aim lower. A 4" ball must not pass, and wood moves: a gap that measures 4" at install can open up as the balusters dry and bow. Most builders space them about 3 1/2" apart.
Are horizontal railings allowed?
The model code does not ban horizontal rails or cable, as long as every opening stops a 4" ball. Some cities do ban them because children can climb them like a ladder, so ask your building department first.
Before you build: most decks attached to a house need a permit, and cities amend the IRC. Bring your layout to the building department and follow the railing maker's instructions; they count as part of the code.
Sources
- 2024 International Residential Code, Chapter 3, International Code Council, Sections R301.5 and R321.1.
- R321.1.3 Opening limitations, Stairbuilders and Manufacturers Association.
- Code-Compliant Guardrails, Journal of Light Construction.
- DCA 6: Prescriptive Residential Wood Deck Construction Guide, American Wood Council.