DeckMath
IRC R312.1.3 · 4-inch sphere

Baluster Spacing Calculator

Even-spacing layout that solves the IRC 2021 R312.1.3 4-inch-sphere rule the right way. Pick a baluster style, enter your railing length, set the section count, and DeckMath returns the exact baluster count, the equal-gap dimension to 1/16″, a side-elevation diagram with dimension lines, and an optional bill of materials with rail kit, brackets, and labor.

IRC R312.1.37 baluster styles1/16″ precisionMulti-section supportSVG elevationBoM + laborFree forever
7·Baluster styles
4"·IRC max gap
PASS/FAIL·Code badge
<2s·Live calc

Inputs

Railing length

Total perimeter that needs balusters.

ft

A section is the run between two posts. 8.0 ft per section.

in

in

68 balusters across 4 sections. Largest gap 3 5/8″. Passes IRC R312.
Layout · IRC R312.1.3·Wood 2×2 (PT pine)
68 balusters3 5/8″ equal gap
Passes R312.1.332 ft total · 4 sections36″ rail height
Balusters / section
4 sections
Equal gap
3.64″ decimal
Total balusters
× 1.5″ face
Project total
Northeast

Compliance · IRC 2021

Passes IRC R312.1.3 — no 4-inch sphere passes through

IRC R312.1.3

Largest gap across all sections: 3 5/8″ (3.64″). IRC R312.1.3 requires every opening in a guard to reject a 4-inch sphere. Your safety target is 3.875″.

36″ rail height — meets IRC R312.1.2 minimum

IRC R312.1.2

IRC R312.1.2 minimum guard height is 36″ for one- and two-family residential. 42″ is required in some jurisdictions and recommended on tall decks.

Side-elevation layout

Actual baluster placement with dimension lines — pin next to the saw on cut day.

section 1 of 4
DeckPOSTPOSTTop rail cap8.00′ (96″) post-to-post3 5/8″ gap (×18)361.5″ facePASS · R312

Section 1 of 4 shown. All sections share identical geometry under equal-section assumption.

Per-section breakdown

SectionInner runBalustersEqual gapStatus
#191173 5/8″ PASS
#291173 5/8″ PASS
#391173 5/8″ PASS
#491173 5/8″ PASS

Bill of materials

Wood 2×2 (PT pine) — balusters
68 balusters × $4.85 each
68 ea
$330
Top + bottom rail kit (wood)
32 lf · $14.00/lf
32 lf
$448
Rail-to-post brackets
16 brackets (4 per section × 4 sections)
16 ea
$51
#8 × 2½″ stainless deck screws
3 boxes × 100 ct ($24/box) — 272 screws total (4 per baluster)
3.0 box
$72
Materials subtotal
$901

National-median pricing 2026-Q1 · Home Depot / Lowe's / specialty railing suppliers. Labor uses Northeast multiplier (1.22×).

Materials
Wood 2×2 (PT pine) BoM + rail kit + screws + brackets
$901
Labor (Northeast)
1.22× national rate
$856
Grand total
Materials + labor for 32 lf railing with 68 balusters.
$1,757

Need a full deck cost?

The Deck Cost Calculator gives you a complete project budget — materials, labor, permits, contingency — across 5 finish tiers.

Open

Layout solves IRC 2021 R312.1.3 (residential guards) using a 3.875″ max-gap target. Stair-side guards use a different rule (R311.7.5.1). Always verify with your local building department before installing. DeckMath is not a substitute for a licensed inspector.

How to use

Three steps. Permit-ready output.

  1. 01

    Measure the railing run

    Tape-measure the total length of railing you're building, in linear feet. Add up every section that has balusters — typically the deck perimeter minus the house side (for a ledger-attached deck) or the full perimeter (freestanding).

  2. 02

    Count your sections

    A 'section' is the run between two posts. Most decks divide the perimeter into 4-8 ft sections at the corners and any intermediate posts. Count each section once. The calculator divides total length evenly across the count to compute layout per section.

  3. 03

    Pick your baluster style

    Wood 2×2 (1.5″ face, classic look, widest gap allowance), wood 1×1 (¾″, modern slim), aluminum square (¾″, powder-coated), aluminum round (5/8″, slimmest sightline), glass panel (no balusters), cable infill (different rule). Each style shows installed price.

  4. 04

    Set the post offset

    Distance from the inside face of the post to the centerline of the first baluster. IRC allows up to 4″ here too, but most pros use 2-3″ for visual symmetry. Smaller offset = more balusters = denser look.

  5. 05

    Set the maximum gap

    Default is 3 7/8″ (1/8″ safety margin under the IRC R312.1.3 cap of 4″). Some inspectors measure with a sphere that's slightly larger than 4″ in tolerance — the safety margin keeps you well clear.

  6. 06

    Read your layout

    PASS/FAIL badge, baluster count per section, equal-gap dimension to 1/16″, side-elevation diagram with dimension lines, and a bill of materials with shop links. Save link, export PDF, embed.

How we calculate

The math, fully transparent.

The Baluster Spacing Calculator solves the IRC 2021 R312.1.3 problem the right way: every gap in a guard system must be small enough that a 4-inch sphere cannot pass through. Enter your total railing length, the number of sections (between intermediate posts), the baluster style and width, and the post offset. DeckMath returns the exact baluster count per section, the equal gap dimension to 1/16″ precision, a PASS/FAIL badge per section against the IRC code, and an optional bill of materials with rail kit, brackets, screws, and labor for any US state. The side-elevation diagram shows the actual layout with dimension lines so you can pin it next to the saw on cut day.

IRC references

  • IRC 2021 R312.1 — Guard required when surface is > 30″ above grade
  • IRC 2021 R312.1.2 — Minimum guard height 36″ (residential)
  • IRC 2021 R312.1.3 — Guard openings ≤ 4-inch sphere (the rule this calc solves)
  • IRC 2021 R311.7.5.1 — Stair guards allow up to 4 3/8″ sphere (different rule)
  • ASTM E2353 — Glass panel guard test method

Solver: even-spacing layout with N = ceil((inner_run − max_gap) / (baluster_width + max_gap)). Pricing 2026-Q1 retail (Home Depot, Lowe's, specialty railing suppliers). Labor multipliers from RSMeans 2026-Q1 residential indices.

Inner section run
inner_run = section_length − 2 × post_offset

The usable width between balusters in a section is the length between posts minus twice the post offset (one offset at each end of the section).

Minimum baluster count
N = ceil((inner_run − max_gap) / (baluster_width + max_gap))

Smallest integer N such that the equal gap is ≤ max_gap. Algebra: starting from gap = (inner_run − N×bw) ÷ (N+1) ≤ max_gap, solve for N.

Equal gap
gap = (inner_run − N × baluster_width) / (N + 1)

Once N is fixed, the remaining length minus all baluster faces, divided by the number of gaps (always N+1), gives the equal-spacing dimension. Rounded to 1/16″ in the diagram.

Total balusters
total = N_per_section × section_count

DeckMath assumes equal sections. For unequal sections, run the calc once per unique section length and sum the counts.

Screw count
screws = total_balusters × 4

Two screws each end (top + bottom rail). Stainless #8 × 2½″ deck screws are sold by the 100-ct box; we round up to whole boxes.

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.

Frequently asked

Questions, answered.

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.

<!-- Drop into any HTML, WordPress, Webflow, or contractor site -->
<script src="https://embed.deckmath.com/v1.js"
        data-deckmath-calc="baluster-spacing-calculator"
        data-theme="auto"
        async></script>