Skip to content
Free Deck Board
Stairs & railings

Deck Railing Height and Baluster Spacing: What Code Requires

When a deck needs a guard, how tall it must be, how to space balusters under the 4-inch sphere rule, and what changes on stairs, with worked spacing examples.

Updated · 8 min read · By Free Deck Board Calculator · How we research

Under the International Residential Code, a deck needs a guard wherever the walking surface is more than 30” above the ground within 36” of its edge. The guard must be at least 36” tall, and no opening in it can let a 4” sphere pass through. Stairs follow slightly different numbers, and handrails are a separate requirement. Many jurisdictions change one or more of these values, so always confirm with your local building department.

This guide covers what each rule means on a real deck, how to space balusters so they pass, and the structural details that matter as much as the dimensions.

Guard vs. handrail: two different things

People say “railing” for both, but the code treats them separately:

  • A guard keeps people from falling off an open edge. It runs along the deck perimeter and up the open sides of stairs.
  • A handrail is something to grab while climbing or descending stairs. It has to be graspable, sit at a set height, and run the full length of the flight.

On stairs, one assembly can do both jobs, but only if it meets both sets of rules. A flat 2x6 cap on top of a stair guard usually does not count as a handrail, because you cannot wrap your hand around it.

When a deck needs a guard

The IRC requires guards on open-sided walking surfaces, including stairs, ramps and landings, “located more than 30 inches measured vertically to the floor or grade below at any point within 36 inches horizontally to the edge of the open side” (IRC R312.1.1, quoted in Simpson Strong-Tie’s code reference).

The 36” horizontal part matters on sloped lots. A deck can be 24” high at its edge, but if the ground falls away to 32” below the deck surface within 3 ft of that edge, a guard is required. Measure at several points, especially where the yard slopes away from the house.

If your deck is under 30” everywhere, a guard is not required by the IRC, but you can still build one. Many homeowners add one along a step-down edge or where kids play.

How tall the guard must be

LocationIRC minimum heightMeasured from
Deck, porch, landing36”Adjacent walking surface
Open side of stairs34”Line connecting the tread nosings
Stair guard that also serves as the handrail34” to 38”Line connecting the tread nosings

Source: IRC R312.1.2 and exceptions, Simpson Strong-Tie code reference.

For comparison, the International Building Code generally requires 42” guards on commercial and multi-family buildings. One- and two-family homes get the 36” exception (IBC 1015.3, same source). Some local codes require 42” on residential decks too, often above a certain height. This is the number most worth checking before you order a railing kit, because kits come in fixed heights.

Built-in benches change the measurement

A bench built into the deck edge gives a child a step up and over the guard. The American Wood Council’s DCA 6 commentary recommends measuring guard height from the seat surface, not the deck, as a best practice. It also says openings under the bench must not pass a 4” sphere. If you plan perimeter seating, raise the guard behind it or keep the bench away from the edge.

The 4-inch sphere rule and baluster spacing

The IRC says required guards “shall not have openings from the walking surface to the required guard height which allow passage of a sphere 4 inches in diameter” (IRC R312.1.3). The rule is sized to keep a small child’s head from fitting through. It applies to every opening, including:

  • the gap between balusters
  • the gap between the bottom rail and the deck surface
  • the gap between the end baluster and the post
  • the gap where a guard meets the house wall

Two openings on stairs get looser limits under the same section:

  • Stair guard infill: openings must not pass a 4-3/8” sphere.
  • The triangle formed by the riser, tread and bottom rail must not pass a 6” sphere.

Why builders aim below 4”

A gap of exactly 4” fails if a baluster bows, shrinks or gets nudged. Wood balusters move as they dry, and inspectors often test with a 4” ball rather than a tape. Most builders aim for a clear gap between 3-1/2” and 3-3/4”. That leaves room for movement and small cutting errors.

Worked example: balusters between two posts

Posts set 6 ft (72”) on center, using 4x4 posts (3-1/2” actual) and 2x2 balusters (1-1/2” actual):

  1. Clear space between posts: 72 − 3.5 = 68-1/2”.
  2. Pick a target gap of 3-3/4” maximum. Each baluster plus one gap takes 1.5 + 3.75 = 5.25”. There is always one more gap than balusters.
  3. Minimum balusters: (68.5 − 3.75) ÷ 5.25 = 12.3, so round up to 13.
  4. Actual gap: (68.5 − 13 × 1.5) ÷ 14 = 49 ÷ 14 = 3-1/2”.

Rip a spacer block to exactly that width and use it for every baluster in the section. Small errors add up over 13 pieces, so check your layout from both posts toward the middle.

The deck railing calculator runs this for each section of your deck, then totals posts, rails and balusters across the whole perimeter.

Horizontal and cable infill

The IRC does not ban horizontal infill, but some local codes do because children can climb it. Cable railing is held to the same 4” rule, and cables deflect when pushed. That means spacing and tension have to follow the system manufacturer’s instructions, often with intermediate supports between posts. Ask your building department before choosing either style.

Strength matters as much as height

A guard that is the right height but pulls loose when someone leans on it is not a guard. Per DCA 6, the IRC requires:

  • guards and handrails to resist a 200 lb concentrated load applied in any direction
  • infill and balusters to resist a 50 lb load applied over 1 sq ft

DCA 6’s prescriptive guard detail uses these assumptions:

  • Posts: minimum 4x4, spaced no more than 6’-0” apart, and not notched at the base.
  • Framing: joists and rim joists that carry guard posts must be at least 2x8.
  • Attachment: two 1/2” through-bolts at the post, plus hold-down connectors with at least 1,800 lb allowable tension for a 36” maximum guard height, installed with blocking per the figures.
  • Balusters: attached top and bottom, either with screws or with nails as specified in the detail.

Notching a 4x4 post to sit “inside” the rim removes much of its cross-section right where the leverage is greatest. That is why DCA 6 labels its posts “DO NOT NOTCH.” If you are using a manufactured aluminum or composite railing system, follow its installation guide and its own tested post-mount details instead.

Guard posts also affect your framing plan. If you know where the posts land before you frame, you can add blocking in the right bays. The deck framing calculator helps lay out joists so posts land where you need them.

Stair handrails

On stairs, DCA 6 summarizes the IRC handrail rules this way:

  • A handrail is required on at least one side of any stair with 4 or more risers.
  • Height is 34” to 38”, measured vertically from the line of the tread nosings.
  • It runs continuously from above the lowest riser to above the highest riser and returns to the guard or a post at each end.
  • It must be graspable. A Type I round rail is 1-1/4” to 2” in diameter. A non-round Type I rail has a perimeter of 4” to 6-1/4” with a maximum cross-section dimension of 2-1/4” (IRC R311.7.8.3, Simpson Strong-Tie code reference). Larger profiles need a finger recess on both sides.
  • Where a handrail mounts on a wall, it needs at least 1-1/2” of clearance from the wall (IRC R311.7.8.2).

A common deck approach: build the stair guard with a flat cap, then mount a separate round or shaped handrail on the inside face of the posts with brackets, set within the 34” to 38” range. For stair geometry, see how to build deck stairs. The deck stair calculator will tell you how many risers you have and whether a handrail is triggered.

Planning the materials

Once the rules are clear, a railing takeoff comes down to counting:

  • Posts: one at every corner, at each end of a run, at the top and bottom of stairs, and intermediate posts so no span exceeds 6 ft (or the railing kit’s limit if shorter).
  • Rails: top and bottom rails for each section, plus a cap if your design uses one.
  • Balusters: calculated section by section with the spacing method above.
  • Fasteners and hardware: bolts and hold-downs per post, screws per baluster. The deck screw calculator handles decking screws. Railing hardware is usually counted per post.

Railings are a larger share of deck cost than many people expect, especially with metal or composite systems. The deck cost breakdown shows where railing fits in the overall budget.

Frequently asked questions

Does a deck under 30 inches need a railing?

The IRC requires guards only where the surface is more than 30” above grade within 36” of the open edge. A lower deck generally does not need one under the model code. Check grade at several points along the edge, because a sloping yard can push part of a low deck over the limit. Your local code may also differ.

Is the 4-inch rule measured center to center or between balusters?

It is the clear opening between the faces of the balusters, not center-to-center spacing. With 1-1/2” balusters and a 3-1/2” clear gap, centers end up 5” apart. Inspectors check the clear gap, often by trying to pass a 4” ball through it.

Can my stair guard double as the handrail?

Yes, if the top rail sits 34” to 38” above the nosing line and meets the graspability rules. A flat 2x6 or 2x4 cap is usually too wide to qualify, so most wood decks add a separate graspable handrail along the stair. Manufactured railing systems often sell a matching handrail kit for this purpose.

Is 36 or 42 inches required for a residential deck?

The IRC minimum for one- and two-family homes is 36”. Some states and municipalities require 42”, sometimes only above a certain deck height. Confirm the local requirement before buying a railing kit, since kits are sold in fixed heights.