Quick answer
Under the 2021 International Residential Code, a deck needs a railing (the code calls it a guard) where the surface is more than 30 inches above the ground within 36 inches of the edge. The guard must be at least 36 inches high, 34 inches on stairs, and no opening may let a 4-inch sphere through. The code sets no post spacing; the American Wood Council's DCA 6 guide uses 4x4 wood posts up to 6 ft apart, which takes 12 wood 2x2 balusters per section.
When a deck needs a railing
Section R312.1.1 of the 2021 IRC requires guards on open-sided walking surfaces, including floors, stairs, ramps and landings, that are more than 30 inches above the floor or grade below at any point within 36 inches horizontally of the open side. So a deck only 24 inches up at the house may still need a guard if the ground drops away near the edge. Insect screening does not count as a guard.
How high the railing must be
- At least 36 inches above the walking surface (R312.1.2).
- On the open sides of stairs, at least 34 inches, measured vertically from a line connecting the stair nosings.
- Where the top of a stair guard also serves as the handrail, between 34 and 38 inches above the nosings.
Baluster spacing: the 4-inch sphere rule
R312.1.3 says required guards may not have openings, from the walking surface up to the required height, that allow a 4-inch sphere to pass. There are two exceptions on stairs: openings in the guard along the open side of a stair may be up to 4-3/8 inches, and the triangle formed by the riser, tread and bottom rail may be up to 6 inches.
The code sets a gap limit, not a baluster count. Between 4x4 posts 6 ft apart on center there are 68.5 inches of clear space, which takes 12 wood 2x2 balusters (1-1/2 inch actual, gaps about 3.88 inches) or 14 metal 3/4 inch balusters (gaps about 3.87 inches). The deck railing calculator works it out for your post spacing.
Post spacing and attachment
The IRC gives no maximum post spacing. For wood guards, the American Wood Council's prescriptive deck guide, DCA 6, shows:
- 4x4 posts at 6 ft maximum spacing, never notched where they attach (IRC R507.10.2 says the same).
- Each post bolted to a 2x8 or larger rim or outside joist with two 1/2 inch through-bolts, plus a hold-down anchor rated at least 1,800 lb for a guard up to 36 inches high. Posts on the outside joist also get blocking in the first joist bay; posts on the rim line up with a joist.
- 2x4 top and bottom rails, 2x2 balusters and a 2x6 or 5/4 rail cap.
DCA 6 is written to the 2015 IRC, and some building departments use it as their deck standard. Composite and other guard systems must carry a label with their maximum span (R507.2.2.1) and be installed per the manufacturer's instructions (R507.2.2.5 and R507.10.4).
How strong it must be
Table R301.5 requires a guard to resist a single 200 lb concentrated load at the top, and balusters and other infill to resist 50 lb on 1 square foot. R507.10.1 requires a continuous load path from the guard to the deck joists, and R507.10.1.1 does not allow connections that rely only on fasteners in end grain.
The 2024 code and local rules
The 2024 IRC keeps the same heights, sphere sizes and loads, with the guard section renumbered R321. Towns adopt and amend the code on their own schedule, so your building department has the final word, and many require a permit for a deck.
Frequently asked questions
How high does a deck railing need to be?
At least 36 inches above the deck surface where a guard is required, and at least 34 inches on the open sides of stairs, under 2021 IRC R312.1.2.
What is the maximum gap between deck balusters?
Openings must not let a 4-inch sphere pass (2021 IRC R312.1.3), so every gap has to be less than 4 inches. On the open side of stairs the limit is 4-3/8 inches.
Does a deck under 30 inches need a railing?
Not under the IRC, unless the ground drops so that the surface is more than 30 inches above grade at any point within 36 inches of the edge. Local codes can be stricter.
How many balusters for a 6 foot railing section?
12 wood 2x2 balusters or 14 metal 3/4 inch balusters between 4x4 posts 6 ft apart on center, which keeps every gap under 4 inches.
Calculators for this
Deck Railing and Baluster
Find how many balusters and posts your deck railing needs.
Deck Framing Planner
Joist and beam size, post spacing, post and footing size and ledger fasteners, with a to-scale framing plan.
Stair Stringer
Enter the total rise to get riser height, step count, stringer length and a to-scale layout diagram with IRC code checks.
Published 2026-11-06. Sources: 2021 International Residential Code, sections R301.5 and R312 (Colorado adoption, via UpCodes); 2021 International Residential Code, section R507.10 (Colorado adoption, via UpCodes); 2024 International Residential Code, chapter 3 (Maryland adoption, via UpCodes); American Wood Council, DCA 6 Prescriptive Residential Wood Deck Construction Guide; NIST PS 20-25, American Softwood Lumber Standard (Table 3, actual sizes); Deckorators, aluminum balusters. See how we calculate.