Deck railing and baluster calculator
| Run | Posts | Post centers | Balusters per bay | Gap |
|---|---|---|---|---|
| 16 ft | 4 | 62 13/16 in | 12 | 3 3/16 in |
| 12 ft | 3 | 70 1/4 in | 13 | 3 3/8 in |
| 12 ft | 3 | 70 1/4 in | 13 | 3 3/8 in |
| Item | Quantity | Price |
|---|---|---|
| 2x2x36 balusters | 88 balusters, 6 packs of 16 | $238.14 |
| 4x4 posts, cut to 44 1/4 in | 8 posts from 4 x 8 ft | $43.12 |
| 2x4 top and bottom rails | 14 pieces from 6 x 8 ft + 4 x 8 ft + 4 x 8 ft | $68.32 |
| 2x6 cap rail | 7 pieces from 1 x 16 ft + 1 x 12 ft + 1 x 12 ft | $47.84 |
| 1/2 x 8 in through-bolts, 2 per post | 16 bolts | $73.76 |
| 1/2 in nuts | 16 nuts, 1 pack of 50 | $25.98 |
| 1/2 in washers, 2 per bolt | 32 washers, 1 pack of 50 | $22.45 |
| 1,800 lb hold-downs, 1 per post | 8 hold-downs | $176.00 |
| 3 in deck screws for balusters, 4 each (our estimate) | 352 screws, 2 boxes of 309 | $65.94 |
$761.55 in materials priced so far. Home Depot Hamilton Mill shelf prices read Oct 8, 2026 to Nov 4, 2026, before tax and delivery. The balusters are priced at the sale price shown on the day, so the regular price is higher.
Baluster Spacing: the 4 Inch Rule
Balusters have one job: keep a child from slipping through the guard. The code test is a 4 in sphere. If it cannot pass between two balusters, or between a baluster and a post, the gap is legal. The rest of the guard has to hold up too: it is 36 in tall and takes a 200 lb push at the top, and it is required once the deck is more than 30 in above grade (IRC R312.1.1 to R312.1.3).
The formula with an 8 ft example
Start with the posts. A run of length L takes n = ceil(L / 72) + 1 posts, spaced evenly, because 72 in is the longest span between guard posts. Each 4x4 post is 3 1/2 in wide, so the clear space between two posts is S = (L - n x 3.5) / (n - 1).
Next, count the balusters in one bay: N = ceil((S - g) / (w + g)). Here g is the gap you aim for, 3 1/2 in by default, and w is the baluster width, 1 1/2 in for a 2x2. The gap you really get is (S - N x w) / (N + 1), and it must come out under 4 in.
Take an 8 ft run, which is 96 in. It needs n = 3 posts. The clear space is S = (96 - 3 x 3.5) / 2 = 42.75 in. Then N = ceil((42.75 - 3.5) / 5) = 8 balusters per bay, and the real gap is 3 7/16 in. The first baluster sits 3 7/16 in off the post and the next ones follow at 4 15/16 in center to center. That makes 16 balusters for the run, 8 in each of two bays.
2x2 wood vs metal balusters
Wood 2x2s are 1 1/2 in wide, and the calculator's metal option is a 3/4 in baluster. The thinner the baluster, the more of them the same bay needs, because each one blocks less of the gap. The same 8 ft run takes 16 wood balusters or 20 metal ones. Follow the maker's instructions for any metal system. Wood 2x2s are sold in packs of 16, and the calculator rounds up to whole packs.
If you want a tighter look, lower the target gap. At 3 in the same 8 ft run takes 18 wood balusters, against 16 at 3 1/2 in.
Railing Post Spacing
6 ft max in DCA 6
The DCA 6 guard detail in Figure 24 shows posts at 6'-0" maximum, and the calculator spaces every run to stay inside that. It does not push posts to the maximum. It adds a post when the run goes past 72 in and then splits the run evenly, so a 12 ft run gets 3 posts about 70 1/4 in apart rather than two bays of 72 in and one short bay. This is the spacing of railing posts, not of the posts that hold up the deck. For those, see the beam span calculator.
Chart for 8, 10, 12 and 16 ft runs
The numbers below come from the same code as the calculator, for 2x2 wood balusters and a 3 1/2 in target gap.
| Run | Posts | Post centers | Clear bay | Balusters per bay | Total | Real gap |
|---|---|---|---|---|---|---|
| 8 ft | 3 | 46 1/4 in | 42 3/4 in | 8 | 16 | 3 7/16 in |
| 10 ft | 3 | 58 1/4 in | 54 3/4 in | 11 | 22 | 3 3/16 in |
| 12 ft | 3 | 70 1/4 in | 66 3/4 in | 13 | 26 | 3 3/8 in |
| 16 ft | 4 | 62 13/16 in | 59 5/16 in | 12 | 36 | 3 3/16 in |
Metal balusters at 3/4 in need 20, 26, 30, 42 for the same four runs.
Rails, Cap and Hardware
A guard has three horizontal parts: a 2x4 at the top and another at the bottom between the posts, with the balusters fixed to them, and a 2x6 cap laid flat over the top rail. The calculator cuts each rail piece between posts and fits the pieces to 8, 10, 12 or 16 ft boards, whichever costs least. It uses 6 pieces for an 8 ft run and 9 for a 16 ft run.
How a post is bolted
A guard post is held to the joist or rim with two 1/2 in through-bolts with washers (DECK-GUARD-02). Put each bolt at least 2 in from the top and bottom edge of the joist, and keep the two bolts 2.5 to 5 in apart so that shrinkage across the grain does not split the board (NDS 11.5.1.3). The joist or rim that carries guard posts should be a 2x8 or larger. Cut the post 44 1/4 in long on a 2x8: 36 in of guard, the decking and the joist depth.
Hold-down
The top bolt also carries a hold-down rated for 1,800 lb, such as the Simpson DTT2Z, which is what keeps a guard from being pulled off the deck when someone leans on it. It goes on 2x blocking between the joists. The calculator counts one per post and lists the bolts, nuts and washers, which are sold by the pack.
With shelf prices read from Oct 8, 2026 to Nov 4, 2026, an 8 ft run comes to $255.07 in materials priced so far, or $31.88 per foot, and a 16 ft run to $395.67, or $24.73 per foot. The short run costs more per foot because the nuts and washers come in packs of 50 and the balusters in packs of 16. The balusters are priced at the sale price shown on the day. Prices are before tax and delivery, from the Home Depot Hamilton Mill store.
When a Deck Needs a Railing
The IRC requires a guard wherever the deck surface is more than 30 in above the ground below (R312.1.1). At 30 in or less, the model code does not ask for one, though your city may. Measure from the top of the deck boards straight down to grade, and use the lowest point along the edge. The deck permit guide covers what a building department usually asks to see.
Stair Railings
A stair guard follows the slope of the stairs, so rails are longer than the horizontal run, while balusters are counted on the level run. Enter the run and the total rise above and the calculator sizes the rails on the slope and measures the gap level.
The model code is a little looser on stairs, and the calculator does not use the slack. IRC R312.1.3 lets a guard on the open side of a stair have openings up to a 4 3/8 in sphere, and the triangle formed by the riser, the tread and the bottom rail up to a 6 in sphere. We keep the stair balusters under 4 in like the rest of the guard, so check only that triangle at each tread. A stair guard is at least 34 in high, measured from the line along the tread nosings, and 34 to 38 in where its top is also the handrail (IRC R312.1.2).
A stair with four or more risers needs a handrail 34 to 38 in above the nosings, graspable and continuous (DECK-STAIR-07). That handrail is separate from the guard. To size the treads and risers first, use the stair stringer calculator, and see the deck stairs guide for landings. Once the railing is built, the deck stain calculator tells you how much stain the rails and boards take.
Want every guard drawn on your own deck? The deck designer and its $49 deck plan place each post and count each baluster from the same rules.
Where the numbers come from
More free calculators
- Deck calculator
- Deck cost
- Joist span
- Beam span
- Stair calculator
- Stair stringer
- Deck footing
- Pergola span
- Paver calculator
- Concrete slab
- Slab cost
- Gravel
- Paver base
- Mulch
- Topsoil
- Raised bed
- Concrete steps
- Cinder block
- Patio cost
- Deck stain
- Retaining wall
- Fence calculator
- Fence post depth
- Concrete for posts
- Fence stain
- Fence cost
- Span tables
Questions
Anything else? Write to us or see every calculator.
Questions people ask
Close enough that a 4 in sphere cannot pass between them, so the clear gap has to stay under 4 in. We aim for 3 1/2 in clear, which for 2x2 balusters is 5 in center to center, and let the calculator spread the last few sixteenths evenly across each bay.
An 8 ft run takes 3 posts and 8 2x2 balusters in each of its 2 bays, 16 in all, with a 3 7/16 in gap. Metal balusters 3/4 in wide need 20. Add a few spares for a bad board.
No more than 6 ft. DCA 6 Figure 24 shows guard posts at 6'-0" maximum. A 12 ft run therefore takes 3 posts, about 70 1/4 in apart.
Find the clear space between two posts, S. The number of balusters in a bay is N = ceil((S - g) / (w + g)), where g is the gap you aim for and w is the baluster width. The real gap is then (S - N x w) / (N + 1). Check that it is under 4 in.
Not under the model code. The IRC requires a guard where the walking surface is more than 30 in above grade (R312.1.1), so a deck 24 in up does not need one. Your city can be stricter, and a railing is still a good idea at that edge. Check with your building department.
Not with the DCA 6 detail, which stops at 6 ft between guard posts. An 8 ft run takes a third post in the middle, so the posts land 46 1/4 in apart. Longer spans need a tested system from a railing maker.