A deck that looks solid can still fail inspection — or worse, fail under a leaning guest — if the railing doesn’t meet the rules. Deck railing code exists for one reason: to keep people from falling off a raised platform and to make sure the barrier holds when someone pushes against it. The requirements come mainly from the International Residential Code (IRC), which most US jurisdictions adopt with local tweaks. Knowing the core numbers before you build saves you from tearing out finished work at inspection time. Here are the rules that matter.
Part of our Decks & Outdoor guide — explore the full guide →
When a Railing Is Required
The first question is whether you even need a guardrail. Under the IRC, a guard is required on any deck, porch, or walking surface that is more than 30 inches above the grade or floor below. Measure the drop within 36 inches horizontally of the deck edge — if that drop exceeds 30 inches at any point, that section needs a guardrail. A ground-level deck a foot off the lawn doesn’t require one; a second-story deck absolutely does.
Required Railing Height
Height is the rule inspectors check first. For residential decks, the guardrail must be at least 36 inches tall, measured from the deck surface to the top of the rail. Some jurisdictions and commercial applications require 42 inches, and many builders default to 42 inches on tall decks for extra safety. Always confirm your local number, because this is one area where cities frequently amend the base code. Build to the higher figure and you’re covered either way.
Baluster Spacing — The 4-Inch Sphere Rule
This is the rule that trips up the most DIY builders. The gaps between balusters (the vertical infill pieces) must be small enough that a 4-inch-diameter sphere cannot pass through. The logic is child safety — a small child’s body shouldn’t be able to slip through or get their head stuck. This applies to the vertical gaps between balusters and to any openings in the railing pattern. In practice, that means balusters are typically spaced about 4 inches on center or less, depending on baluster width.
A related rule covers the triangular gap at the bottom of stairs formed by the tread, riser, and bottom rail: that opening must not allow a 6-inch sphere to pass.
Load Requirements — Strength You Can’t See
A railing that meets the height and spacing rules can still fail code if it’s not strong enough. The IRC requires that a guardrail withstand a 200-pound concentrated load applied in any direction along the top rail. That’s meant to simulate an adult falling or leaning hard against it. Meeting this number is mostly about how the posts are attached — the connection at the deck framing is where railings actually fail. Bolting posts through the rim joist with proper hardware, rather than just toe-screwing them to the surface, is what delivers the required strength.
Stair Railings and Graspable Handrails
Stairs add their own layer of rules:
- A handrail is required on at least one side of any stair with four or more risers.
- Handrail height must be between 34 and 38 inches, measured vertically from the stair nosing.
- The handrail must be graspable — a specific cross-section (round handrails roughly 1-1/4 to 2 inches in diameter, or an equivalent graspable profile) so a hand can wrap around it. A wide flat 2×4 laid on edge does not qualify as a graspable handrail.
- Guardrails still apply on stairs where the drop exceeds 30 inches, in addition to the handrail.
Post Spacing and Attachment
While the IRC doesn’t fix a single universal post-spacing number, posts are commonly set no more than 6 to 8 feet apart so the railing meets the load requirement without excessive flex. The critical detail is attachment: posts should be through-bolted to the deck framing with carriage bolts or tension-rated hardware, and blocking added between joists where needed to stop the post from twisting. Notching posts weakens them, so many code officials prefer solid, unnotched posts bolted to the rim.
Ledger and the Bigger Picture
Railing code doesn’t exist in isolation — inspectors evaluate the whole deck’s safety. The ledger board attaching the deck to the house must be properly bolted and flashed, and the overall structure must carry the required loads. A perfect railing on a poorly attached deck still fails. When you pull a permit, expect the inspector to look at footings, ledger, joist hangers, and railing together.
Always Pull the Permit and Check Local Amendments
The single best advice: contact your local building department before you build. Most deck work requires a permit, and inspection is where these code numbers get enforced. Local jurisdictions routinely amend the IRC — a common example is requiring 42-inch guards instead of 36, or stricter footing depths for frost. Building without a permit can mean fines, forced removal, and problems when you sell the house, since unpermitted decks show up in inspections.
The Bottom Line
Understanding deck railing code comes down to a handful of numbers: guards on drops over 30 inches, a minimum 36-inch (often 42-inch) rail height, gaps that block a 4-inch sphere, a 200-pound load capacity, and graspable handrails on stairs with four or more risers. Build to those standards, bolt your posts to the framing properly, and pull a permit so an inspector can confirm it. A code-compliant railing isn’t red tape — it’s what keeps your family and guests from a serious fall.