Home › Decking › Deck Railing Calculator
Deck Railing Calculator
Source: IRC R312 · guard load Table R301.5
Work out how many balusters and posts a deck guard needs, and what gap that actually leaves. The sphere rule is not one number — the code sets three different limits depending on where you are on the deck, and this page applies the right one.
Baluster & post calculator
Checked against IRC R312: guard required over 30 in (R312.1.1), minimum 36 in high (R312.1.2), sphere limits per R312.1.3. Post spacing is not a code figure — see below.
Worked example
A 20 ft run of guard on a deck 48 in above grade, 4×4 posts at 6 ft maximum spacing, with square 2×2 balusters that measure 1½ in.
- Is a guard required? 48 in is over the 30 in trigger in R312.1.1, so yes — and it must be at least 36 in tall (R312.1.2).
- Posts. 20 ft ÷ 6 ft = 3.33, rounded up to 4 bays, which needs 5 posts.
- Clear span per bay. 240 in of run less 5 posts × 3.5 in = 222.5 in of infill, divided by 4 bays = 55 5/8 in per bay.
- Balusters. To keep every gap under 4 in each bay needs 10 balusters — 40 in total — leaving an actual gap of 3 11/16 in. Ten is the minimum that passes; more is fine, fewer is not.
- Check the bottom. The 4 in sphere applies to the gap under the bottom rail too, not just between balusters.
Move the same railing to the open side of the stair and the infill limit becomes 4⅜ in rather than 4 in — but a second limit appears that does not exist on the level deck: the triangular opening formed by the riser, tread and bottom rail must not pass a 6 in sphere. Three different sphere sizes on one deck, which is why a calculator that reports "4 inches" is not telling you enough.
The formula
Baluster spacing is a packing problem, not a lookup. For a clear span between posts, the balusters and the gaps have to add up exactly:
- L
- clear span between posts, in
- n
- number of balusters in the bay
- w
- actual baluster width, in — a 2×2 measures 1.5, not 2
- g
- resulting gap between balusters, in
- gmax
- largest gap the code allows — 4 in, or 4⅜ in on the open side of a stair
There is one more gap than there are balusters, which is the step people miss: with 13 balusters in a bay there are 14 gaps, because the gaps at each post count. Solving for n and then recomputing g gives an even, code-legal layout instead of a full-size gap at one end and an offcut at the other.
What the code actually says
R312.1.1 Where required. Guards go on open-sided walking surfaces — including stairs, ramps and landings — that sit more than 30 in above the floor or grade below, measured at any point within 36 in horizontally of the open edge. That horizontal clause matters on sloping ground: a deck that is 26 in above the grade right at the edge can still need a guard if the ground drops away within 36 in.
R312.1.2 Height. Not less than 36 in, measured vertically above the adjacent walking surface or, on a stair, above the line connecting the nosings. Guards along a stair may be 34 in.
R312.1.3 Opening limitations — three different limits. On a level guard, no opening may pass a 4 in sphere. On the open side of a stair, the infill limit relaxes to 4⅜ in. And the triangular opening formed by the riser, the tread and the bottom rail of the guard is limited to a 6 in sphere. Most calculators report only the first.
Table R301.5 Loads. A guard must take a 200 lb concentrated load applied at any point along the top, and the infill components must take 50 lb applied over a one-square-foot area. Where the top of the guard also serves as a handrail, that 200 lb load applies in any direction; otherwise it is applied downward and horizontally away from the walking surface.
Post spacing is not in the code. The IRC prescribes the loads, not a spacing table. The commonly used 6 ft maximum comes from the American Wood Council's DCA 6, Prescriptive Residential Wood Deck Construction Guide, and from railing manufacturers' own instructions. If you are using a manufactured railing system, its instructions govern and often specify tighter spacing. Treat the 6 ft default here as a convention to check against your system, not as a code limit.
Why the guard fails inspection, and it is rarely the balusters
Baluster spacing is easy to get right and easy to see, so it gets the attention. The 200 lb load in Table R301.5 is what actually governs, and it concentrates at the post-to-frame connection. A 4×4 post notched around the rim joist and through-bolted behind the notch has lost most of its section exactly where the moment is highest. This is why guard posts are detailed with tension ties or blocking in DCA 6 rather than simply lag-screwed to the rim — and why a guard can have textbook 3 in gaps and still be rejected.
Deck railing height — 36 or 42 inches
36 in is the residential minimum under R312.1.2. The 42 in figure people quote comes from the IBC, which governs commercial and most multi-family construction — it is not the number for a single-family deck. Building higher than 36 in is allowed and some jurisdictions amend upward, so confirm locally rather than assuming either figure. Note also that the height is measured from the walking surface, so a guard measured before the decking goes down will end up short by the thickness of a board.
Frequently asked questions
- How far apart can deck balusters be?
- Close enough that a 4 in sphere cannot pass through any opening (IRC R312.1.3). With 1½ in balusters that works out to roughly 5⅜ in on center. On the open side of a stair the limit is 4⅜ in instead.
- At what height does a deck need a railing?
- More than 30 in above the floor or grade below, measured at any point within 36 in horizontally of the open edge (R312.1.1). On ground that slopes away, measure at the lowest point within that 36 in — not at the edge.
- How tall does a deck railing have to be?
- At least 36 in for a one- or two-family dwelling (R312.1.2), measured from the walking surface. Along a stair it may be 34 in. The 42 in figure is the commercial IBC number and does not apply to a house deck.
- Is the sphere really 4 inches everywhere?
- No, and this is the most common mistake. It is 4 in on a level guard, 4⅜ in on the open side of a stair, and 6 in for the triangular opening formed by the riser, tread and bottom rail.
- How many balusters do I need for 20 feet?
- With 5 posts at 6 ft maximum spacing and 1½ in balusters, 40 — ten per bay across four bays — leaving a 3 11/16 in gap. That is the minimum that keeps a 4 in sphere out; tightening the spacing is always allowed. Change the post width or spacing and the number moves, so run your own figures above.
- How far apart should railing posts be?
- The IRC does not say. Six feet is the common maximum, from AWC's DCA 6 and from manufacturers' instructions. What the code does specify is the 200 lb load the post has to carry, which is what the spacing is really about.
- Does the gap under the bottom rail count?
- Yes. The sphere rule applies to every opening in the guard, including between the bottom rail and the deck surface. Leaving a generous drainage gap there is a routine way to fail.
Check these numbers yourself
- ICC Digital Codes — the IRC itselfInternational Code Council. Free to read online; registration required.
- AWC DCA 6 — Prescriptive Residential Wood Deck Construction GuideAmerican Wood Council, free PDF. The prescriptive deck guide the IRC deck provisions track.
- IRC R312 — Guards and window fall protectionUpCodes. This one defaults to odd jurisdictions -- check the code named at the top of the page.
Figures on this page last checked against the source documents on 2026-09-05. Codes are amended locally; confirm against the edition your jurisdiction enforces.
Related calculators
Estimates only. This applies the prescriptive limits in IRC R312 and the loads in Table R301.5 for planning purposes. It is not a structural design. Post spacing here follows DCA 6 convention rather than code, and manufactured railing systems are governed by their own instructions. Guards exist to stop people falling — confirm every dimension and the post attachment detail against the code edition and amendments your building department enforces.