DeckMath
railing · guardrail · stair handrail · IRC R312

Railing Linear Feet Calculator

How much railing do you actually need? DeckMath sums perimeter minus house-attached sides minus gates, plus angled stair handrail (hypotenuse), with material-specific post spacing (4-6′ o.c.). 5 tiers from PT cap ($24/lf · DIY) to tempered glass ($105/lf · luxury). Auto IRC R312 guard-height flag + R311.7.8 stair-handrail check.

Start calculating
Get 2–3 free quotes
4 shapes · rect / L / U / custom5 materialsIRC R312 + R311Auto post countBoM + share + PDF
5·Material tiers
4-6′·Post spacing o.c.
36/42″·Guard height
R312·IRC code

Inputs

Deck shape

Main rectangle

ft

ft

Full perimeter56
Open (after attached)40
Guard LF (after gates)40
in

⚠ IRC R312 — 36″ guardrail required.

Stairs

in

in

Hypotenuse / stringer5.48
Handrail LF (all stairs)5.48

Results

IRC R312 guardrail required (36″) · IRC R311 stair handrail required · DIY tier 1

Total railing
order 48.66′ (7% waste)
Posts
6′ max o.c.
Project total
Low $4,056 · Northeast
$/lf installed
Low $89

Perimeter diagram

1612house1 stair
Railing required (40′) House-attached (no rail) Stair (5.48′ handrail)

Guardrail required — 36″ off grade ≥ 30″

IRC R312.1.1 + R312.1.2

IRC R312.1.2 mandates a 36″ minimum guardrail on the open sides of decks more than 30″ above grade. 40 LF of guardrail in the BoM.

Stair handrail required — 5 risers ≥ 4

IRC R311.7.8.1 + R311.7.8.4

IRC R311.7.8.1 requires a handrail on at least one side of stairs with 4+ risers. 5.48′ hypotenuse per side · one side × 1 stair = 5.48 LF of angled handrail. Returns at top + bottom (R311.7.8.4) included as bracket-kit line item.

Post spacing — max 6′ o.c. (12 posts total)

IRC R312.1.4 + manufacturer spec

6′ max post spacing meets IRC R312.1.4 + manufacturer spec. Composite sleeves slip over a 4×4 PT structural post.

4″ sphere rule — opening limit verified

IRC R312.1.3.1 + R312.1.3.3

IRC R312.1.3.1 requires that a 4″ sphere cannot pass through any guardrail opening. Baluster centers at ≤4″ (use the Baluster Spacing Calculator to size individual baluster placement once total LF is set). Stair triangle (R312.1.3.3) limited to 4-3/8″ — handrail brackets account for this.

Material tier 1 — DIY-friendly

Manufacturer install spec

Best value mid-market. Color-matched cap, 25-yr warranty, no repaint. DIY-friendly w/ pre-cut kits.

Composite cap rail w/ aluminum balusters (Trex Signature / TT Classic)
49 lf ordered · 45 lf actual · 7% waste · $42/lf installed-equiv
49 lf
$2,044
Composite-sleeve 4×4 posts (matching cap)
12 posts · 10 guard + 2 stair posts · max 6′ o.c.
12 post
$1,020
Surface-mount post bases (Simpson APB / DTT2Z)
12 post bases bolted through decking into framing
12 ea
$312
Stair handrail brackets + returns (IRC R311.7.8.5)
4 brackets · code-compliant 1.5″ wall clearance · returns at top/bottom
4.0 ea
$56
Materials subtotal
$3,432

Cost breakdown

Materials
$3,157 – $3,432
Labor
$899 – $1,099
Soft costs
$0 – $0
Subtotal
$4,056 – $4,530
Contingency (8%)
$362
Project total
$4,056 – $4,893
Cost per linear foot (45.48 lf)
$89 – $108

2026-Q1 pricing. Ranges reflect contractor vs DIY purchase, regional supplier variance, and the 7% material waste typical of composite cap rail w/ aluminum balusters (trex signature / tt classic). Permit fees are average residential — your local AHJ may charge more. Always verify code with your local inspector before ordering.

How to use

How to use the railing linear-feet calculator in 5 steps.

  1. 1

    Pick the deck shape

    Rectangle (most common — 2L+2W perimeter), L-shape (main rect + leg, minus shared edge), U-shape (main rect + two legs), or Custom LF for unusual layouts. For Custom, enter the total OPEN perimeter directly (already net of attached sides). L and U-shape inputs accept the secondary leg's length × width independently.

  2. 2

    Set deck dimensions + attached sides

    Length × width in feet. Attached-sides count: 0 = freestanding (full perimeter needs rail), 1 = one side against house (subtract length), 2 = corner-nested (subtract length + width). House-attached sides don't need guardrail per IRC — only the open sides do.

  3. 3

    Enter stair geometry

    Stair count (0-3 landings), total rise (deck height to grade in inches), and total run (stringer horizontal in inches). DeckMath computes the stringer hypotenuse via √(rise² + run²) and adds that length per stair side. Toggle 'handrail both sides' for wider stairs (>44″) per IRC R311.7.8.

  4. 4

    Add gates if any

    Each gate subtracts 3 feet from the guardrail LF (standard residential gate width). Gates are separately costed line items with self-closing + child-safe latch hardware (pool-code compliant). 0-4 gates supported.

  5. 5

    Pick material tier + state

    PT cap ($24/lf, DIY tier 1), composite cap ($42/lf, DIY tier 1 — best value), cable ($58/lf, DIY tier 2 — premium open view), glass ($105/lf, pro-only tier 3 — luxury), aluminum ($48/lf, DIY tier 1 — fastest install). State selection adjusts labor cost via regional multipliers (12 US regions).

How we calculate

How DeckMath calculates this — IRC 2021 sources.

The Railing Linear Feet Calculator sizes the total guardrail + handrail you need for a deck — perimeter minus house-attached sides minus gates, plus the angled stair handrail run, with code-compliant post layout. Pick deck shape (rectangle, L-shape, U-shape, or custom LF), attached-side count, stair geometry, and one of five material tiers: pressure-treated cap rail ($24/lf · DIY), composite cap ($42/lf · best value), cable ($58/lf · open view), glass ($105/lf · luxury), or aluminum picket ($48/lf · low maintenance). DeckMath returns ordering LF including waste, post count at material-specific max spacing (4-6′ o.c. per IRC R312 + manufacturer instructions), the IRC-required guard height (36″ or 42″), and a BoM with installed-cost ranges accounting for regional labor (12 US regions) and permit fees. Distinct from the Baluster Spacing Calculator (D.1, MVP) which fills a known railing length with code-compliant balusters — this calc tells you HOW MUCH RAIL you need before you start measuring balusters.

IRC references

  • IRC 2021 R312.1.1 — Guards required on open sides of decks > 30″ above grade
  • IRC 2021 R312.1.2 — Guard height 36″ minimum (residential); 42″ above 6′ in some jurisdictions
  • IRC 2021 R312.1.3.1 — 4″ sphere rule (no opening allows passage of 4″ sphere through guardrail)
  • IRC 2021 R312.1.3.3 — Stair triangle 4-3/8″ opening limit
  • IRC 2021 R311.7.8.1 — Handrail required on at least one side of stairs with 4+ risers
  • IRC 2021 R311.7.8.3 — Continuous handrail along entire stair flight; returns at top/bottom
  • IRC 2021 R311.7.8.5 — Handrail clearance 1.5″ minimum from wall
  • IRC 2021 R301.5 — Guard live load 50 lb single point applied any direction

Railing pricing 2026-Q1: PT cap $24/lf, composite cap $42/lf (Trex Signature / TimberTech Classic), aluminum picket $48/lf (Westbury / Fortress), cable rail $58/lf (Feeney / Atlantis), tempered glass $105/lf (10mm panel). Labor $12-45/lf by material. Waste 4-10% by material. Post spacing per IRC R312.1.4 + manufacturer.

Rectangle perimeter
P = 2·(L + W)

Sum of all four sides. 16×12 rectangle = 56 LF perimeter. With 1 house-attached side (length = 16′), open perimeter = 40 LF.

L-shape perimeter
P = 2·(L + W) + 2·(L₂ + W₂) − 2·shared

Main rectangle plus leg rectangle, minus twice the shared edge where the leg attaches to the main. For a 16×12 main + 8×6 leg (shared edge = 6′): 56 + 28 − 12 = 72 LF.

Stair handrail hypotenuse
H = √(rise² + run²) / 12

Stringer length per stair. For a 36″ rise + 55″ run stair: √(36² + 55²) / 12 = √(1296 + 3025) / 12 = √4321 / 12 ≈ 5.48 LF per side. Two-side stairs (>44″ wide) double this.

Ordering LF (with waste)
L_order = L_total × (1 + waste%)

Waste varies by material: PT cap 10% (miter cuts + end loss), composite 7%, cable 4% (cut-to-length kits), glass 5%, aluminum 6%. For 40 LF composite cap: 40 × 1.07 = 42.8 LF ordered.

Post count
n = corners + ceil(L_guard / max_spacing) + stair_posts

Cable rail max spacing is 4′ (tension load); composite/PT/aluminum/glass all permit up to 6′. For 40 LF of cable rail in a rectangle: 4 corners + ceil(40/4) − 4 + 1 = 11 posts (guard) + 2 stair posts = 13 total.

IRC guard height
Deck > 30″ above grade → 36″ guard required (R312.1.2)

Residential decks above 30″ must have a 36″ minimum guard. Some jurisdictions require 42″ above ~72″ (commercial threshold). DeckMath flags 42″ when deck height > 72″ as a code-safety hint.

Save your plan

Don’t lose this estimate.

Your inputs are preserved in the URL — email it to yourself or copy the link so you can compare with contractor bids later. No account needed.

Get matched

Want 2–3 free quotes for this exact deck?

We'll send your plan to vetted local builders. Free, no obligation.

People also ask

Railing linear-feet questions, answered.

  • Full rectangle perimeter is 2·(16+12) = 56 LF. If one side is attached to the house (most common), subtract the 16′ attached side: 40 LF of guardrail. Add ~5.5 LF per stair side for one set of stairs. So a typical 16×12 deck with one house-attached side and one stair landing needs about 46 LF of guardrail + handrail. Order 10% extra (≈51 LF) for end cuts and miter waste.

  • IRC 2021 R312.1.1 requires a 36″ guardrail on any deck surface more than 30 inches above the grade below. Stair handrail is required (R311.7.8.1) on any stair with 4 or more risers — typically when total stair rise exceeds 24 inches. DeckMath auto-flags both code triggers based on deck height and stair rise inputs. Below 30″ deck height with no stairs, railing is optional (aesthetic).

  • Installed material + labor by tier: pressure-treated cap rail $36-50/lf (DIY-friendly), composite cap $60-85/lf (best value), aluminum picket $64-90/lf (fastest install), cable rail $86-120/lf (premium open view), tempered glass panel $150-200/lf (luxury). A 40 LF guardrail in composite cap typically lands $2,400-3,400 installed. Cable adds ~40% over composite. Glass adds ~150%.

  • Material and manufacturer drive the maximum spacing. Cable rail systems limit to 4 feet on-center (cable tension creates significant horizontal load on end posts). Composite cap, PT cap, aluminum, and glass all allow up to 6 feet on-center. Corner posts always required regardless of spacing. For a 40 LF straight run with composite cap: 4 corners + ceil(40/6) − 4 + 1 = 8 posts minimum. Cable on the same run needs 11 posts.

  • IRC R311.7.8.1 requires handrail on AT LEAST ONE side of stairs with 4+ risers. Both sides are required only when the stair is wider than 44 inches per R311.7.8.2 — most residential deck stairs are 36-42″ wide, so one side is fine. Local AHJs may require both sides for stairs that serve as the only egress from a deck above 6′ — check your inspector.

  • For a 36″ rise + 55″ run stair (typical 5-riser deck stair): √(36² + 55²) ÷ 12 = 5.48 LF of angled handrail per side. Round to 6 LF for ordering. The angled handrail returns to the post at top and bottom (IRC R311.7.8.4) — DeckMath includes the bracket count + return-fittings cost in the BoM. For a 96″ deck height with two 4′ landings, total handrail run is ≈25 LF per side.

  • Material cost: PT cap rail is roughly 60% the per-LF cost of composite cap ($24 vs $42 per LF). But total installed cost narrows the gap: PT labor is similar to composite, and PT requires repainting every 2-3 years. Over a 25-year horizon, composite cap costs less than PT once you factor 8-12 repaint cycles. PT wins on year-1 cash outlay only.

  • Yes — common patterns include composite cap rail on the long open sides + cable infill on the view side (best of both worlds). DeckMath's calculator handles one material at a time, but you can run it twice (once per material zone) and sum the LF for each. Post spacing must drop to the most-restrictive zone's max (e.g., a cable section forces 4′ o.c. across that section).

  • Yes. Each gate opening (standard 36″ = 3 feet) subtracts from the guardrail LF because the gate itself replaces a section of rail. DeckMath's BoM treats gate hardware as a separate line item (~$185 per gate kit, including self-closing hinges and child-safe latch). Gates around pool decks must meet local AHJ requirements — typically self-closing + auto-latching with the latch ≥54″ from grade per ISPSC.

  • Frameless glass railing systems (Q-railing, Easy Glass) use channel mounts in the deck framing instead of vertical posts — the glass itself is the structure. They cost $180-250 per LF installed, require 12mm tempered laminated glass per IBC, and need an engineered base channel. DeckMath's 'glass' option assumes top-rail framed glass with aluminum posts; for frameless, multiply by ~1.7× and consult a glass specialist.

Embed this calculator

One line. Any site. Free.

Drop the snippet into your contractor site, blog, or marketing page. Theme matches the parent site automatically.

<!-- Railing Linear Feet Calculator — free embed by DeckMath -->
<a href="https://deckmath.com/calculators/railing-linear-feet-calculator"
   data-deckmath-calc="railing-linear-feet-calculator"
   data-theme="auto">Free Railing Linear Feet Calculator by DeckMath</a>
<script src="https://embed.deckmath.com/v1.js" async></script>
One tool · free · no signup

Plan the whole project, not just one number

The Deck Project Planner turns your dimensions into a complete material list, cost, 3D preview, and a PDF you can take to the lumber yard — all in one place.