Tell it about your deck or stairs. You get whether the code asks for a guard, how tall it must be, where the handrail goes, and how many balusters to buy and where to mark them.
Your railing
A 36″ guard with 13 balusters36″ off the ground is over 30″, so the code asks for a guard · gaps of 3⁹⁄₁₆″, every 5¹⁄₈″ on centres
Quick answer: under the IRC a deck, porch or balcony more than 30″ off the ground needs a guard at least 36″ high (42″ in California and in public buildings), with no gap that lets a 4″ ball through. A stair with 4 or more risers needs a handrail 34–38″ above the nosings; a stair’s guard is 34″ above them, its gaps under 4⅜″.
How to use the railing calculator
- Pick what the railing is for: a deck, porch or balcony (a level floor), or stairs.
- Pick the code. Most US homes are built to the International Residential Code (IRC); California’s residential code changes one number, the guard’s height; a shop, an office or an apartment block’s common areas follow the International Building Code (IBC).
- For a deck, measure from the deck boards straight down to the ground at the edge, then the clear space between two posts, face to face, and the width of one baluster. Add how many sections of that size you have to get the number to buy.
- For stairs, count the risers (the steps up, including the last one onto the deck or floor), and measure one riser’s height, the tread from nosing to nosing, and how far the nosing overhangs the riser below it.
- You get whether a guard is required and how tall, where the handrail goes, how many balusters keep every gap under the code’s ball and where to mark them, drawn to scale.
The rules behind the numbers
When a deck needs a guard
Guards go on “open-sided walking surfaces, including floors, stairs, ramps and landings that are located more than 30 inches (762 mm) measured vertically to the floor or grade below at any point within 36 inches (914 mm) horizontally to the edge of the open side” (IRC R312.1.1). Measure at the lowest ground within 36″ of the edge, not at the house: a yard that falls away can put a low deck over the line.
How tall the guard is
The IRC asks for guards “not less than 36 inches (914 mm) in height as measured vertically above the adjacent walking surface or the line connecting the nosings” (R312.1.2). California’s 2022 residential code amends that to “not less than 42 inches (1067 mm)”; Washington’s state code keeps 36″. In public and commercial buildings the IBC asks for 42″ (1015.3). On a stair’s open side a house guard may be 34″ above the nosings, and 34–38″ when its top rail is the handrail (R312.1.2, exceptions).
Baluster spacing: the 4″ ball
“Required guards shall not have openings from the walking surface to the required guard height that allow passage of a sphere 4 inches (102 mm) in diameter” (R312.1.3). On a stair’s open side the ball is 4⅜″, and the triangle between a tread, its riser and the guard’s bottom rail may pass up to a 6″ ball (R312.1.3, exceptions). The IBC uses 4″ to a height of 36″ and 4⅜″ from there to 42″, and the same 6″ triangle (1015.4).
Handrails on stairs
“Handrails shall be provided on not less than one side of each flight of stairs with four or more risers” (R311.7.8), their tops “not less than 34 inches (864 mm) and not more than 38 inches (965 mm)” measured “vertically from the sloped plane adjoining the tread nosing” (R311.7.8.1), continuous from above the top riser to above the lowest (R311.7.8.4), 1½″ from a wall (R311.7.8.3), and graspable: round 1¼–2″ across, or a perimeter of 4–6¼″ no wider than 2¼″ (R311.7.8.5). In a public building, stairs have handrails on each side (IBC 1011.11) that run 12″ flat past the top riser and one tread at the slope past the bottom one (1014.6), as the ADA Standards ask (§505.2, §505.10).
Railing heights by code
| Home (IRC) | California home | Public building (IBC) | |
|---|---|---|---|
| A guard is required | over 30″ up | over 30″ up | over 30″ up |
| Deck, porch or balcony guard | 36″ | 42″ | 42″ |
| Guard on a stair’s open side | 34″ (34–38″ as the handrail) | 34″ (34–38″ as the handrail) | 42″ |
| Handrail on stairs | 34–38″, one side, 4+ risers | 34–38″, one side, 4+ risers | 34–38″, both sides |
| Largest ball through a deck guard | under 4″ | under 4″ | under 4″ (4⅜″ above 36″) |
| Largest ball through a stair guard | under 4⅜″ | under 4⅜″ | under 4″ |
| The triangle under a stair’s bottom rail | under 6″ | under 6″ | under 6″ |
How many balusters per section
The fewest balusters that keep every gap under the 4″ ball, by the clear space between the posts (gaps shown to the 1/16″ below):
| Between posts | 1½″ balusters (2×2) | Gap | ¾″ balusters (metal) | Gap |
|---|---|---|---|---|
| 36″ | 6 | 3¹³⁄₁₆″ | 7 | 3¹³⁄₁₆″ |
| 48″ | 9 | 3⁷⁄₁₆″ | 10 | 3⁵⁄₈″ |
| 60″ | 11 | 3⁵⁄₈″ | 12 | 3⁷⁄₈″ |
| 72″ | 13 | 3³⁄₄″ | 15 | 3³⁄₄″ |
| 84″ | 15 | 3¹³⁄₁₆″ | 17 | 3¹⁵⁄₁₆″ |
| 96″ | 17 | 3⁷⁄₈″ | 20 | 3¹³⁄₁₆″ |
Balusters per stair tread
Under the 4⅜″ ball for a stair’s side, by the tread’s depth (nosing to nosing):
| Tread | 1½″ balusters | Gap | ¾″ balusters | Gap |
|---|---|---|---|---|
| 10″ | 2 | 3¹⁄₂″ | 2 | 4¹⁄₄″ |
| 10½″ | 2 | 3³⁄₄″ | 3 | 2³⁄₄″ |
| 11″ | 2 | 4″ | 3 | 2⁷⁄₈″ |
| 11½″ | 2 | 4¹⁄₄″ | 3 | 3¹⁄₁₆″ |
| 12″ | 3 | 2¹⁄₂″ | 3 | 3¹⁄₄″ |
Four worked examples
A deck 3′ off the ground, posts 70″ apart, 2×2 balusters. Over 30″, so it needs a 36″ guard. 13 balusters per section leave gaps of 3⁹⁄₁₆″: mark the first centre 4³⁄₈″ from the post, then every 5¹⁄₈″.
A second-floor balcony in California, six 44″ sections, ¾″ metal balusters. A 42″ guard; 9 balusters per section, 54 in all, gaps of 3¹¹⁄₁₆″.
Six steps down from a deck: 7½″ risers, 10½″ treads, a 1″ nosing. 45″ in all, so a handrail on one side at 34–38″ above the nosings. Only the 5th tread is more than 30″ up, so the guard is required there; at 2 balusters per tread the gaps are 3³⁄₄″, under the 4⅜″ ball. A bottom rail must sit within ⁹⁄₁₆″ of the nosing line, or the balusters run down to the treads.
A porch 24″ off the ground. Not over 30″: the code asks for no guard. A railing added anyway is not held to the 4″ ball, but 13 balusters in a 70″ section keep the same gaps a required one has.
Common railing mistakes
- Measuring the height at the house. The 30″ is to the lowest ground within 36″ of the edge.
- Spacing balusters 4″ apart. A 4″ gap lets the 4″ ball through; every gap must be a little under.
- Forgetting the gap under the bottom rail. It is an opening too: under 4″ from the deck boards.
- Measuring a stair’s handrail from the back of the tread. It is measured straight up from the line across the nosings.
- A 2×6 cap as the stair handrail. Its perimeter is 14″; a handrail is round and 1¼–2″ across, or 4–6¼″ round, or has a finger recess (R311.7.8.5).
- Raising a stair guard’s bottom rail for looks. A rail an inch or two above the nosings can open the triangle past 6″: check it here.
A permit office can amend any of these numbers: check with yours before you build. Lay out the steps with the stair rise and run calculator, a ramp with the wheelchair ramp calculator, and plan the deck itself in the free 2D planner.
Stair rise & runRead next
- Deck railing designs
- Balcony railing designs
- Stair railing ideas
- Front porch stair ideas
- DIY outdoor stairs
Railing and handrail questions
What is the standard stair railing height?
At a house, a stair’s handrail is 34–38″ above the nosings (IRC R311.7.8.1), and the guard on its open side is at least 34″ above them; where the guard’s top rail is the handrail, 34–38″ (R312.1.2). In a public building the stair’s guard is 42″ (IBC 1015.3) with a 34–38″ handrail on each side.
What is the handrail height for stairs?
34–38″, measured straight up from the sloped line across the tread nosings, by both the IRC (R311.7.8.1) and the IBC (1014.2), and the ADA Standards (§505.4). A house needs one on at least one side of any flight with four or more risers.
What is the deck railing height code?
36″ at least under the IRC (R312.1.2), for a deck more than 30″ above the ground within 36″ of its edge (R312.1.1). California’s residential code asks for 42″, and so does the IBC for a public or commercial building.
Does a deck need a railing?
When any part of it is more than 30″ above the ground within 36″ of its edge (R312.1.1). Lower than that, the code asks for none, though you may build one.
What is the code for baluster spacing?
No gap may let a 4″ ball through (IRC R312.1.3), so the gaps are a little under 4″. On a stair’s open side the ball is 4⅜″, and the triangle under a stair guard’s bottom rail is held to 6″.
How many balusters do I need?
For a clear space S between posts and balusters w wide, the fewest that work are the first whole number above (S − 4) ÷ (w + 4): 13 for 70″ of 2×2s, gaps of 3⁹⁄₁₆″. Multiply by the number of sections.
What is the banister height?
A banister is the stair’s handrail: 34–38″ above the nosings (R311.7.8.1), continuous from above the top riser to above the lowest one (R311.7.8.4).