Deck Railing Calculator
This free deck railing calculator turns one length into a complete guard take-off. Enter the total run of level railing, pick your post size and spacing, choose a baluster style, and it counts posts (one per bay plus one per corner), balusters spaced so no 4-inch sphere passes, top and bottom rails, an optional 2×6 cap rail, deck screws, rail connectors, and a code-required hold-down at every post. For 1½-inch square balusters at a 4-inch gap that lands near the jobsite rule of thumb of about two balusters per linear foot.
The spacing math is the part people get wrong. IRC R312.1.3 says no opening in a level guard may pass a 4-inch sphere, so the calculator solves for an even gap under 4 inches across each bay and reports the exact result. Stairs use a looser 4-3/8-inch sphere on the rake plus a 6-inch sphere at the tread triangle, and they need a separate graspable handrail 34–38 inches high (IRC R311.7.8) — enter the stair rake length and those get counted too. Cable rail switches to horizontal runs at 3 inches or tighter, because cable deflects.
The other quiet code item is attachment: a guard that passes the sphere test still fails inspection if the posts are only screwed to the rim. IRC Table R301.5 puts a 200-pound concentrated load at the top, so the calculator budgets a tension-tie or through-bolt hold-down at every post and follows AWC DCA 6 for post size and spacing. No pricing, no signup — just the materials list. Confirm your local amendments, which most often raise the guard to 42 inches.
Deck Railing Calculator
Get a complete deck railing take-off — posts, balusters, rails, cap, and the fasteners and hold-downs to attach them — from one length. Balusters are spaced so no 4″ sphere passes (IRC R312.1.3), posts follow AWC DCA 6, and every post gets a hold-down for the 200 lb code load. Handles wood, metal, and cable infill, plus stair railing. Free, no signup.
Railing length & posts
Total length of level guard railing (sum every guarded side — skip the house wall and any gate openings). Posts round up and add one per corner; verify against your post layout.
Guard height & infill
IRC R312.1.2 sets a 36″ minimum guard on decks. The infill is spaced so no 4″ sphere can pass (IRC R312.1.3).
Rails & caps
Top and bottom rails run the full length. Add a top cap rail (2×6) to walk drinks along, and decorative post caps.
Stairs (optional)
Length of guard along the stair rake (the slope), if any. Stair guards use a 4-3/8″ sphere and need a graspable handrail (IRC R311.7.8).
Calculation Formulas
The number of infill sections between posts. Post spacing is capped by the post size and hardware, not by an IRC number — DCA 6 keeps 4×4 guard posts within about 6 ft.
Example:
40 LF ÷ 6 ft = 6.67 → 7 bays
A continuous run needs one more post than bays; each 90° corner forces one extra post the straight division would otherwise span. Rounds up — an extra post is cheap insurance. Verify against your layout.
Example:
7 bays + 1 + 2 corners = 10 posts
Fills a single clear opening (post spacing minus one post width) so that N balusters create N+1 equal gaps, each at or under the maximum. Clear opening uses the dressed post width (3½″ for a 4×4).
Example:
68.5″ opening, 1½″ baluster, 4″ gap → ⌈(68.5−4)/5.5⌉ = 12 balusters
The resulting even gap must be at or under 4 in. for a level guard so a 4 in. sphere cannot pass (IRC R312.1.3).
Example:
(68.5 − 12×1.5) ÷ 13 = 3.88″ ✓ (< 4″)
For 1½ in. square balusters at a 4 in. gap this works out to roughly two balusters per linear foot of railing — the common jobsite rule of thumb.
Example:
12 × 7 bays ≈ 84 (≈ 2 per ft over ~42 ft of bays)
A standard guard runs a top and a bottom rail the full length. An optional cap rail (2×6) adds one more length. Pieces are cut from the longest stock to minimize joints.
Example:
2 × 40 = 80 LF ÷ 16 ft = 5 rail pieces
Two deck screws per baluster — one into the top rail, one into the bottom rail. Metal balusters use connectors at the same rate.
Example:
84 balusters × 2 = 168 screws
Horizontal cable is spaced at 3 in. or less because cable deflects — most inspectors will not accept the 4 in. sphere test at wider spacing. Intermediate pickets hold tension on long runs.
Example:
(36 − 4) ÷ 3 = 10 cable runs
The stair guard uses the 4-3/8 in. sphere (IRC R312.1.3), so balusters sit slightly farther apart than a level guard but run along the longer sloped rake distance.
Example:
10 LF rake, 1½″ baluster → ⌈120 / 5.875⌉ = 21 balusters
Standard Constants
| Constant | Value | Description |
|---|---|---|
| Guard required above | 30 in | IRC R312.1.1 — a guard is required where the walking surface is more than 30 in. above the grade or floor below. |
| Minimum guard height (deck) | 36 in | IRC R312.1.2 — measured vertically from the deck surface. Some jurisdictions require 42 in. |
| Level-guard sphere | 4 in | IRC R312.1.3 — no opening in a level guard may pass a 4 in. sphere. |
| Stair-rake sphere | 4-3/8 in | IRC R312.1.3 — the open guard on the stair rake may pass a 4-3/8 in. sphere. |
| Stair triangle sphere | 6 in | IRC R312.1.3 — the triangle at the tread, riser, and bottom rail may pass a 6 in. sphere. |
| Guard top load | 200 lb | IRC Table R301.5 — a single concentrated 200 lb load applied at the top in any direction; drives the post hold-down. |
| Guard infill load | 50 lb / sq ft | IRC Table R301.5 — infill components resist a 50 lb load over a 1 sq ft area. |
| 4×4 post spacing | ≤ 6 ft | AWC DCA 6 practical maximum for a hold-down-anchored 4×4 guard post; 6×6 for longer. |
| Stair handrail height | 34–38 in | IRC R311.7.8 — graspable handrail height above the stair nosings. |
Note: All calculations include appropriate waste factors based on project complexity and material type. Results are estimates and should be verified by professionals before purchasing materials.
IRC R312 — Guards(IRC R312)
View StandardGoverns where guards are required, their height, and the opening (sphere) limitations for both level runs and stairs on residential decks and porches.
Key Requirements:
- •Guard required where the walking surface is more than 30 in. above grade (R312.1.1).
- •Minimum guard height 36 in. on decks, measured from the walking surface (R312.1.2).
- •No 4 in. sphere through a level guard; 4-3/8 in. on the stair rake; 6 in. at the stair triangle (R312.1.3).
IRC Table R301.5 — Live Loads (Guards & Handrails)(IRC R301.5)
View StandardSets the structural load a guard and its infill must resist, which determines how posts are attached to the deck frame.
Key Requirements:
- •200 lb concentrated load applied at the top of the guard in any direction.
- •50 lb load over a 1 sq ft area on the infill (balusters/panels).
- •Guard posts require a hold-down (tension tie) or through-bolts — not deck screws or a lag into the rim.
AWC DCA 6 — Prescriptive Deck Guide(DCA 6)
View StandardThe American Wood Council prescriptive guide that most jurisdictions accept for residential wood decks, including guard-post size, spacing, and tested hold-down connections.
Key Requirements:
- •4×4 guard posts spaced within about 6 ft; 6×6 for taller or longer spans.
- •Posts anchored with a tested hold-down (e.g., Simpson DTT2Z) or blocking + through-bolts.
- •Notching guard posts is limited — follow the guide’s tension-tie details.
IRC R311.7.8 — Stair Handrails(IRC R311.7.8)
View StandardRequires a continuous, graspable handrail on stairs, separate from the guard, at a set height above the nosings.
Key Requirements:
- •Handrail height 34–38 in. above the stair nosings.
- •Continuous along the full run with returns at both ends.
- •Graspable cross-section (Type I or Type II per R311.7.8.3).
ICC-ES / Manufacturer Listings — Guard Systems(ICC-ES ESR)
View StandardPre-manufactured metal, composite, and cable guard systems carry evaluation reports specifying tested post spacing, infill, and connection details that supersede the generic prescriptive rules.
Key Requirements:
- •Follow the listed maximum post spacing for the specific system.
- •Use the system’s specified brackets, tensioners, and end fittings.
- •Cable systems: intermediate supports at the listed interval to limit deflection.
Standards Disclaimer: Standards and codes are subject to periodic updates. Always verify current requirements with local building authorities and professional engineers before beginning construction. Links provided are for reference only.
Guard Height: 36 in. vs 42 in.
Base IRC vs local amendment
The IRC minimum is 36 in. on residential decks, but many jurisdictions (and all commercial work) require 42 in. A taller guard changes baluster length and can add a mid-rail.
Regional Examples:
Post Attachment / Hold-Downs
The most-failed inspection item
A guard that passes the sphere test still fails if the posts are only screwed or lagged to the rim. DCA 6 and most inspectors require a tested tension-tie or through-bolted connection to resist the 200 lb top load.
Regional Examples:
Cable Railing Spacing
Deflection vs the sphere test
Horizontal cable can technically meet a 4 in. sphere at wider spacing, but because cable deflects under load many AHJs require 3 in. or tighter and intermediate pickets on long runs. Some jurisdictions restrict horizontal (ladder-effect) infill for homes with young children.
Regional Examples:
Material & Climate
Corrosion and wood species
Coastal and treated-lumber environments accelerate fastener corrosion. ACQ/CA pressure-treated lumber requires hot-dipped-galvanized or stainless hardware; stainless cable and fittings are standard near salt air.
Regional Examples:
Stair Guard & Handrail
Rake sphere and graspability
Stairs carry their own rules: the 4-3/8 in. rake sphere, the 6 in. triangle, and a separate continuous graspable handrail 34–38 in. high with returns. Balusters on the rake are plumb, not perpendicular to the slope.
Regional Examples:
Before You Build
- •Contact your local building department for specific requirements
- •Verify frost line depths, wind zones, and seismic requirements for your area
- •Check if permits are required and schedule required inspections
- •Consult with a local contractor familiar with local codes
Plan disposal before you start
Smaller jobs still produce more debris than a few trash bags can hold. Check what's allowed in a dumpster and which disposal option fits the scope.
See disposal options →
Related Calculators
Deck Calculator
Code-compliant deck framing, decking, footings, ledger, stairs & railing — built on 2021 IRC R507 and AWC DCA 6 tables. Free, no signup.
Stairs Calculator
Code-compliant stair geometry, stringers & materials per 2021 IRC R311.7 / 2024 R318.7. Straight, L, U, winder, spiral & curved. AWC DCA 6 stringer spans. Free.
Deck Stain Calculator
Instantly calculate deck stain gallons by wood type—cedar, pine, composite. Covers surface, railings & stairs separately. Free, fast, no signup needed.
Fence Calculator
Instantly calculate fence posts, rails, pickets & concrete for wood, vinyl & chain link fences. Follows IRC post-spacing standards. Free, no signup.
How to Use This Calculator
- Enter the total length of level deck railing — add up every guarded side, and skip the house wall and any gate openings.
- Set the number of 90° corners and pick your post size (4×4 or 6×6) and maximum post spacing (6 ft is typical for a 4×4).
- Choose the guard height (36 in. IRC minimum, or 42 in. where required) and a baluster or infill style — wood, metal, or cable.
- Pick the maximum baluster gap; 4 in. is the IRC level-guard limit, or tighten to 3½–3¾ in. for a kid-safe deck.
- Turn the top cap rail and post caps on or off, and enter a stair rake length if your deck has stairs.
- Click Calculate to get posts, balusters at the exact even gap, rails, cap, fasteners, hold-downs, and stair railing — then check the code notes.
What this calculator does and does not include
This calculator sizes the guard (railing) itself — posts, balusters or cable, top and bottom rails, an optional cap, the fasteners, and a hold-down at every post — under the residential rules of IRC R312 and the AWC DCA 6 deck guide. It does not size the deck framing (use the Deck, Joist Span, and Deck Beam Span calculators for that), it does not include stair stringers or treads (use the Stairs calculator), and it is a prescriptive material take-off, not an engineered design. Guard height, post attachment, and cable spacing are the most commonly amended items at the local level, so confirm with your building department before ordering — an inspector can reject a finished guard that misses a local amendment. Post counts round up and add one per corner; verify the total against your actual post layout.
Frequently Asked Questions
How many balusters do I need for my deck railing?
The rule of thumb is about two balusters per linear foot of railing for standard 1½-inch square balusters at a 4-inch gap, so ~80 for a 40-foot deck. The exact count comes from the spacing rule, not the rule of thumb: IRC R312.1.3 says no opening may pass a 4-inch sphere, so for each bay (the clear opening between two posts) the calculator solves N = ⌈(opening − 4) ÷ (baluster width + 4)⌉ and checks that the resulting even gap is under 4 inches. Narrower metal balusters (½–¾ inch) need more pieces per bay; wider posts and tighter gaps also raise the count.
What is the maximum spacing between deck balusters?
A 4-inch sphere must not pass through a level deck guard (IRC R312.1.3), so balusters are spaced to keep every gap at or under 4 inches. With 1½-inch square balusters that means an on-center spacing of about 5½ inches. On the stair rake the limit loosens to a 4-3/8-inch sphere, and the triangular opening at the tread, riser, and bottom rail may pass a 6-inch sphere. Many builders tighten level-guard gaps to 3½–3¾ inches on decks used by small children — the code number is a maximum, not a target.
How far apart should deck railing posts be?
The IRC does not give a single number, but the AWC DCA 6 prescriptive deck guide keeps 4×4 guard posts within about 6 feet, and 6×6 posts for taller guards or longer spans. Closer is stronger. The reason spacing matters is the load: IRC Table R301.5 requires the guard to resist a 200-pound concentrated load at the top, and a 4×4 anchored with a proper hold-down at 6 feet is the tested limit. Space posts evenly, add one at every corner and at each end, and put one wherever a stair meets the deck.
How tall does a deck railing have to be?
IRC R312.1.2 requires a guard at least 36 inches high on decks, measured vertically from the deck surface to the top of the rail. A guard is required in the first place wherever the walking surface is more than 30 inches above the grade or floor below (R312.1.1). Many jurisdictions — and all commercial work — require 42 inches, so confirm locally before you buy posts and balusters. Taller guards change the baluster length and sometimes add a mid-rail; the calculator lets you pick 36 or 42 inches.
How do I attach deck railing posts so they pass inspection?
This is the most-failed part of a deck guard. Screwing or lagging a post to the rim joist does not resist the code load — IRC Table R301.5 applies a 200-pound force at the top, which levers hard on the base. DCA 6 and most inspectors require a tested hold-down (a tension tie such as a Simpson DTT2Z) or through-bolts with blocking at every guard post. The calculator budgets one hold-down per post for exactly this reason. Notching posts is limited without engineered hardware, so follow the DCA 6 tension-tie details.
How is cable railing spaced on a deck?
Cable rail uses horizontal runs instead of vertical balusters, spaced at 3 inches or tighter — not 4. Even though a 3-inch spacing technically clears the 4-inch sphere, cable deflects when pushed, so most building departments require ≤3-inch spacing and intermediate pickets or supports on runs longer than about 4 feet to hold tension. The calculator counts runs as ⌊(guard height − 4) ÷ 3⌋ and tallies the tensioner and end fittings. Some family-housing codes discourage horizontal (ladder-effect) infill entirely, so check locally.
What does this calculator not include?
It sizes the guard itself — posts, balusters or cable, top and bottom rails, an optional cap, fasteners, and a hold-down per post — plus stair railing if you enter a rake length. It does not size the deck framing (use the Deck, Joist Span, and Deck Beam Span calculators), it does not include stair stringers or treads (use the Stairs calculator), and it is a prescriptive material take-off, not an engineered design. Post counts round up and add one per corner, so verify against your actual layout, and always confirm local code amendments before ordering.