Decks & Stairs

Deck Railing and Baluster Calculator

Enter the length of each railing side. You'll get the posts, the balusters per section with gaps under the building code's 4-inch limit, and the rails to buy.

  • 2021 IRC guard rules
  • AWC DCA 6 post spacing
  • Feet or metric

1 Your measurements

Type feet and inches the way you'd write them, like 12' 6" or 30 3/8. Decimals work too.

ft
Measure along the edge where the railing goes. Leave out the stair opening, and add one post for each opening, since the runs on either side of it don't share a post.
ft
Sides join at corner posts, as around three sides of a deck.
ft
ft
AWC DCA 6 allows up to 6 ft for wood guards with 4x4 posts. For a composite or metal kit, use the span on its label.

2 What to buy

Updates as you type
Balusters
81
2x2 wood (1-1/2 in), gaps up to 3.88 in
Posts
8
4x4, 7 sections
Railing length
40 ft
each of top rail, bottom rail and rail cap
Side 1: 12 ft2 sections with posts 6 ft on center; 12 balusters per section, 3.88 in gaps
Side 2: 16 ft3 sections with posts 5.33 ft on center; 11 balusters per section, 3.67 in gaps
Side 3: 12 ft2 sections with posts 6 ft on center; 12 balusters per section, 3.88 in gaps
Gap limitEach gap must be less than 4 in (2021 IRC R312.1.3: no 4 in sphere may pass)
Guard heightAt least 36 in above the deck surface (R312.1.2)

Corners share one post, so the sides are counted as one continuous railing. If a side ends at the house wall, the last post can be replaced by a wall attachment the manufacturer or your building department approves. Check each gap with a 4 in ball or block after installing: a twisted baluster can open a gap.

Shopping list

Quick answer

The building code requires that no opening in a deck guard lets a 4-inch ball through, and the American Wood Council's deck guide spaces 4x4 posts up to 6 ft apart. A 6 ft section between 4x4 posts takes 12 wood 2x2 balusters (gaps about 3.88 in) or 14 metal 3/4 in balusters. Railing three sides of 12, 16 and 12 ft takes 8 posts and 81 wood balusters.

Balusters for common railing lengths

Railing lengthPosts2x2 wood balustersMetal 3/4 in balusters
8 ft31618
10 ft32024
12 ft32428
16 ft43336
20 ft54048
24 ft54856
30 ft66070
40 ft88491

One straight run, 4x4 posts no more than 6 ft apart, gaps under 4 in. Use the calculator above for your exact size.

The code rules for deck railings

  • When you need one: 2021 IRC section R312.1.1 requires a guard where the walking surface is more than 30 inches above the floor or grade below, at any point within 36 inches of the open edge.
  • Height: at least 36 inches above the deck surface (R312.1.2), and at least 34 inches on the open sides of stairs, measured from the line of the stair nosings.
  • Openings: no opening from the deck surface to the required height may let a 4-inch sphere pass (R312.1.3). On the open sides of stairs the limit is 4-3/8 inches, and the triangle under the bottom rail at the stair can be up to 6 inches.
  • Strength: Table R301.5 requires guards to resist a 200 lb concentrated load at the top and infill such as balusters to resist 50 lb on 1 square foot. Section R507.10.1 requires a continuous load path from the guard to the deck joists.

The 2024 IRC keeps the same values, renumbered as section R321. Your city or county may amend them, so check with your building department.

Post spacing

The IRC itself sets no post spacing. The American Wood Council's prescriptive deck guide, DCA 6, shows a wood guard with 4x4 posts at a 6 ft maximum spacing, 2x2 balusters between 2x4 top and bottom rails, and a 2x6 or 5/4 rail cap. Posts must not be notched where they attach to the deck (IRC R507.10.2), and DCA 6 attaches each one with two 1/2 inch through-bolts and a hold-down anchor rated at least 1,800 lb (for a guard up to 36 inches high; a taller guard needs engineered or listed hardware). Composite guards use the span on their label (R507.2.2.1), and other systems follow the manufacturer's instructions (R507.10.4).

How many balusters per section

Between 4x4 posts 6 ft apart on center there is 72 − 3.5 = 68.5 inches of clear space (a 4x4 is 3-1/2 inches actual). With n balusters there are n + 1 gaps, and each must be under 4 inches:

Posts on centerClear space2x2 wood (1-1/2 in)Metal (3/4 in)
4 ft44.5 in8 balusters, 3.61 in gaps9 balusters, 3.78 in gaps
5 ft56.5 in10 balusters, 3.77 in gaps12 balusters, 3.65 in gaps
6 ft68.5 in12 balusters, 3.88 in gaps14 balusters, 3.87 in gaps

A gap just under 4 inches meets the rule but leaves no room for a bowed or twisted baluster, so check the finished railing with a 4-inch block, and add a baluster to any section that is close.

Worked example

A deck railed on three sides of 12, 16 and 12 ft, with posts no more than 6 ft apart: the 12 ft sides get 2 sections each and the 16 ft side gets 3 sections (posts 5.33 ft apart). That is 7 sections and 8 posts, with the corner posts shared, and 81 wood 2x2 balusters.

Frequently asked questions

How far apart should deck balusters be?

Close enough that no gap lets a 4-inch sphere through, under 2021 IRC R312.1.3. Between 4x4 posts 6 ft apart, that takes 12 wood 2x2 balusters or 14 metal 3/4 in balusters.

How high does a deck railing have to be?

At least 36 inches above the deck surface where a guard is required, and at least 34 inches on the open sides of stairs, under 2021 IRC R312.1.2. Some local codes require more.

When does a deck need a railing?

When the deck surface is more than 30 inches above the ground at any point within 36 inches of the edge, under 2021 IRC R312.1.1.

How far apart can deck railing posts be?

The IRC sets no number. The American Wood Council's DCA 6 guide shows 4x4 wood posts at a 6 ft maximum spacing; composite and metal systems use the span on their label.

Last reviewed 2026-11-06. See how we calculate for our sources and assumptions.

Add this calculator to your website

Free for blogs, contractors and DIY sites. Paste this where you want the calculator to appear. It resizes itself and works on phones.

Please keep the credit line. The calculator updates automatically when we improve it. Preview the widget.