These are the model code's numbers and one state's changes to them. Your state or city decides what applies where you live, so confirm with the local building department before you buy a railing.
The numbers
The building code's word for a deck railing is a guard. Here are its limits in the 2021 International Residential Code, next to California's version:
| Where | Model code | California |
|---|---|---|
| Deck, porch or landing | 36 in or more | 42 in or more |
| Open side of stairs | 34 in or more | 34 in or more |
| Stair guard that's also the handrail | 34 to 38 in | 34 to 38 in |
| Biggest gap in a guard | 4 in | 4 in |
| Biggest gap on the open side of stairs | 4⅜ in | 4⅜ in |
| Triangle under a stair guard | 6 in | 6 in |
Washington's state code uses the same heights as the model code, and the City of Gilroy's handout sets out California's. You'll also see 42 inches quoted for apartments and commercial buildings. That comes from a different code, the International Building Code, which doesn't cover a single-family house.
When you need one
A guard is required on any open side that's more than 30 inches above the floor or ground below. The part people miss is where that's measured. The code doesn't only look straight down from the edge. It looks at any point within 36 inches of the edge.
So the yard matters. Take a deck whose floor is 26 inches above the ground at its edge, on a yard that keeps falling away. If the ground is more than 30 inches below the floor anywhere within 3 feet of that edge, that side needs a guard, even though the edge itself is under the limit. Measure on the low side of the deck before you decide you can skip it.
How it's measured
On a deck, the height runs from the walking surface straight up to the top of the guard. On stairs, it runs up from an imaginary line connecting the front edges of the treads.
Because it starts at the walking surface, new boards can change it. Replace 1-inch boards with 2×6s, which are 1½ inches thick, and the floor comes up half an inch. A railing that was exactly 36 inches is now 35½. If you're resurfacing a deck with thicker boards, measure the railing again afterward.
The gaps
A 4-inch ball shouldn't be able to pass through any opening in the guard. That's the size the code uses to keep a small child from slipping through. On the open side of stairs the limit is a little looser, at 4⅜ inches. The triangle formed by a tread, a riser and the bottom rail can be up to 6 inches.
Our railing calculator explains why cable railing has trouble passing this test.
How strong it has to be
Height isn't the whole job. Guards and handrails have to resist a 200-pound load applied at any point along the top. That applies even to a guard you weren't required to build.
The weak point is usually the post. A post screwed only to the outside of the rim board can work loose over time. The American Wood Council's free guide, DCA 6, shows post connections that bolt through the framing, and building departments often expect to see those on the plans.
Handrails are a separate rule
A guard stops you falling off the side. A handrail is something to hold while you climb. Stairs can need one, the other or both:
- A guard if the open side of the stairs is more than 30 inches above the ground.
- A handrail on at least one side if the flight has four or more risers, set 34 to 38 inches above the line of the treads.
A handrail has to be something a hand can close around, so a flat 2×6 on top of the railing doesn't count. A round rail is typically limited to 2 inches across. The deck stair calculator flags when your stairs reach four risers.
Fair questions
My deck is 24 inches off the ground. Do I need a railing?
Not under the model code, as long as the ground doesn't drop past 30 inches within 3 feet of the edge. Plenty of people with small children add one anyway. The height and gap limits apply to required guards, but the 200-pound strength rule applies to any guard you build.
Is there a maximum height?
Not for a guard on a deck. The only upper limit is the 38 inches on stairs, when the top of the guard is also doing the job of the handrail.
Can I build 42 inches everywhere, to be safe?
On the deck itself, yes, though it cuts into the view from a chair. On stairs, a guard that's also your handrail still has to stay within 34 to 38 inches, or you'll need a separate handrail. Railing kits are commonly sold in both 36- and 42-inch heights, so check which your town wants before you order.
Does a railing have to be a railing?
The code cares about what a guard does, not what it looks like. Glass, cable and metal panels are all fine if they meet the height, gap and strength rules.
What does a deck railing cost?
Forty feet of wood railing is about $1,280 installed at our prices, and the same length in aluminum is about $2,400. The railing calculator prices your length.
Sources
- Washington Administrative Code 51-51-0312, Section R312: the guard rule in a state code built on the 2021 IRC: when a guard is needed and how high it has to be.
- City of Gilroy, California, Residential stairways, handrails and guards: California's rule of 42 inches for guards, with its stair heights and gap sizes.
- Fine Homebuilding, Guardrails vs handrails: where do you need them?: the difference between the two, gap sizes, handrail size and the 200-pound load rule.
- Viewrail, IBC vs IRC railing code requirements: why apartments and commercial buildings use 42 inches and houses 36, and which buildings each code covers.
- American Wood Council, DCA 6: Prescriptive Residential Wood Deck Construction Guide: ledger attachment, joist spans, guards and stairs for wood decks.
- International Residential Code: sections R312 (guards), R311.7.8 (handrails) and R507 (decks). Your city or state adopts and amends it, so check the local version.
- How we calculate: every suggested price behind this calculator, with the date it was last reviewed.