Skip to content
Design free

Deck railing and baluster calculator

Enter each railing run. We space the posts, spread the balusters evenly so no gap reaches 4 in, and list the rails, hardware and what to buy.

You need 8 posts, 88 balusters and 21 rail pieces (top, bottom and cap). The widest gap between balusters is 3 3/8 in, under the 4 in limit.
Layout of each run
RunPostsPost centersBalusters per bayGap
16 ft462 13/16 in123 3/16 in
12 ft370 1/4 in133 3/8 in
12 ft370 1/4 in133 3/8 in
What to buy, Home Depot Hamilton Mill
ItemQuantityPrice
2x2x36 balusters88 balusters, 6 packs of 16$238.14
4x4 posts, cut to 44 1/4 in8 posts from 4 x 8 ft$43.12
2x4 top and bottom rails14 pieces from 6 x 8 ft + 4 x 8 ft + 4 x 8 ft$68.32
2x6 cap rail7 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 post16 bolts$73.76
1/2 in nuts16 nuts, 1 pack of 50$25.98
1/2 in washers, 2 per bolt32 washers, 1 pack of 50$22.45
1,800 lb hold-downs, 1 per post8 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.

Gaps are measured level, between the faces of the balusters, and kept under 4 in on the stairs too, inside the 4 3/8 in the code allows there. The triangle under the bottom rail at each tread must not pass a 6 in sphere. Post length is 44 1/4 in. Screws are counted at 4 per baluster, our own estimate.

Draw the whole deck with its guards

The deck plan ($49) draws every guard run and post from these same rules and counts the balusters for your exact deck.

Planning figures for a residential guard, not an engineer's design. Check your local code, your railing maker's instructions and your joist size before you build.

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.

Guard posts and 2x2 balusters by run length
RunPostsPost centersClear bayBalusters per bayTotalReal gap
8 ft346 1/4 in42 3/4 in8163 7/16 in
10 ft358 1/4 in54 3/4 in11223 3/16 in
12 ft370 1/4 in66 3/4 in13263 3/8 in
16 ft462 13/16 in59 5/16 in12363 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

The guard rules are from the 2021 IRC, R312.1.1 to R312.1.3, and the DCA 6 deck guide: a guard where the deck is more than 30 in above grade, 36 in high, a 4 in sphere that must not pass, and a 200 lb load at the top (rule DECK-GUARD-01). The 6 ft post limit is DCA 6 Figure 24 (ED-06). The two 1/2 in bolts per post are DECK-GUARD-02, and the handrail height on stairs is DECK-STAIR-07.

Aiming for a 3 1/2 in gap instead of the full 4 in is our editorial choice (ED-07), to leave room for a cut that runs a little long. Prices are Home Depot Hamilton Mill shelf prices, each dated on the material list, before tax and delivery. Screws at 4 per baluster, two at each end, are our own estimate. The stair exceptions (a 6 in sphere at the tread triangle, 4 3/8 in on the open side of stairs) and the 34 in stair guard height are IRC R312.1.2 and R312.1.3 as adopted in the 2015 Seattle Residential Code.

More free calculators

  • Deck calculator

    Joists, beam, posts, decking, hardware and concrete for a deck of any size.

  • Deck cost

    What your deck costs in wood or composite, per sq ft and installed.

  • Joist span

    The smallest joist that spans your distance, and how far it can overhang.

  • Beam span

    How far apart the posts can be for a 2-ply or 3-ply built-up beam.

  • Stair calculator

    Steps, riser, tread, run, angle and stringers for any stair, drawn to scale.

  • Stair stringer

    Steps, riser and tread sizes, stringer count and board length from a total rise.

  • Deck footing

    Footing size, depth and concrete bags for the whole deck.

  • Pergola span

    How far a pergola beam and rafters can span, and what limits them.

  • Paver calculator

    Pavers, gravel base, sand, edging and polymeric sand for a patio.

  • Concrete slab

    Cubic yards, 80 lb and 60 lb bags, gravel, mesh and control joints for a slab.

  • Slab cost

    What a slab costs in bags, in ready-mix or hired out, per sq ft.

  • Gravel

    Cubic yards, tons and bags of gravel for any shape and depth.

  • Paver base

    Gravel base, bedding sand and dig depth under pavers.

  • Mulch

    Cubic yards and bags of mulch for a bed of any shape.

  • Topsoil

    Cubic yards, tons and bags of topsoil or fill dirt.

  • Raised bed

    Cut list, boards, screws and soil for a wood raised bed of any size.

  • Concrete steps

    Risers, landing and concrete for poured steps.

  • Cinder block

    Concrete blocks, mortar and grout for a block wall.

  • Patio cost

    What a paver, concrete, stamped or flagstone patio costs, materials and installed.

  • Deck stain

    Gallons of stain or sealer for the deck floor, railings and stairs.

  • Retaining wall

    Blocks, caps, base and drain gravel for a segmental block wall.

  • Fence calculator

    Posts, rails, pickets, concrete and hardware for a wood fence.

  • Fence post depth

    How deep to dig by the 1/3 rule and your frost line, and what post to buy.

  • Concrete for posts

    Bags of fast-setting or regular concrete per post and for the fence.

  • Fence stain

    Gallons of stain for a privacy or picket fence.

  • Fence cost

    What a wood fence costs in materials, per linear foot.

  • Span tables

    The joist, beam and post tables from DCA 6, by species and spacing.

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.