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.
Specification summary
Generated from on . Reopen that address to reproduce these figures exactly.
Entered
Result
Prices for decking materials and labor
Worked example
- 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.
The formula
- 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)
What the code actually says
Why the guard fails inspection, and it is rarely the balusters
Deck railing height: 36 or 42 inches
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.
- What is the spacing for deck spindles?
- Spindles are another name for balusters, and the rule is the same: no opening in the guard may pass a 4 in sphere under R312.1.3. Enter the spindle width in the baluster width box and the count and gap come out the same way. A spacer block cut to the gap the calculator returns keeps every spindle at that spacing as you fasten them.
- Do staircase and cable railings follow the same rules?
- A staircase guard follows R312 with two differences: the sphere on the open side of a stair is 4 3/8 in, and the guard along the stair may be 34 in high. A cable railing has to keep out the same 4 in sphere as any other infill, and the cable tension and post spacing that achieve that come from its manufacturer.
- What does vinyl or aluminum railing installation cost?
- HomeAdvisor's guide to building a deck prices railings at $35 to $210 per linear foot and does not split that range by material, so vinyl and aluminum railing fall inside the same row. On the 20 ft run in the worked example that is $700 to $4,200. A manufactured vinyl or aluminum system also carries its own instructions for post spacing, which often sit tighter than the 6 ft default here.
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, so check the code named at the top of the page.
How every figure here is verified: Sources & Method. Who builds this: Lucas Pradella, and the method is on About. Found something wrong? Tell us and it gets fixed or removed.
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
- Deck Cost Calculator what the whole deck costs
- Deck Beam Calculator IRC Table R507.5(1)
- Joist Calculator IRC Table R507.6
- Flagstone Patio Calculator Coverage per ton from a supplier's own sheet
- Stair Construction Calculator IRC R311.7
- Deck Post Calculator IRC R507.4
- Privacy Fence Calculator picket & post layout
- Deck Fastener Calculator screw & hanger counts
- Deck Lumber Calculator board takeoff
Guides that use this calculator
- Deck Railing and Guard Code Requirements when a guard is required, the three sphere sizes, and where post spacing really comes from
- How to Pour Concrete Stairs the riser math the code enforces, the concrete it implies, and why a per-step price cannot be right
More of them: all guides.
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.