Railings

Baluster spacing calculator

Enter the rail length between two posts and the baluster width. The calculator returns how many balusters the section needs and the even gap between them. At the default 4 inch max gap, no opening is wide enough to pass a 4 inch sphere, which is the IRC guard rule. Further down, a deck railing calculator lays out the posts on every run and totals the balusters for the whole deck. Both run the same math as the CutOnce app.

Scott Brady

By

Software engineer in Seattle and DIY builder who builds the CutOnce construction calculator.

Updated

The short answer

Keep every clear gap between balusters at 4 inches or less (IRC R312.1.3, the 4 inch sphere rule, numbered R321.1.3 in the 2024 edition). For the count, divide the rail length between posts by the baluster width plus 4, and round up. Spread that many balusters evenly and the actual gap lands at or under 4 inches. A 6 ft rail in 1.5 in balusters takes 14, with a 3.40 in gap.

Enter the clear opening between posts the way your tape reads: 6 ft, 72, or 5 ft 11-1/2 in. The IRC 4 in sphere rule caps the gap at 4 in; drop it lower for a tighter look.

Balusters14
Actual gap
3.40 in
Center to center
4.90 in
App StoreGoogle Play
Free to download. 7-day trial of everything.

On this page

The 4 inch sphere rule

A guard on a deck or balcony has to stop a 4 inch sphere from passing through any opening, and a stair guard has nearly the same limit. The limit is sized so a small child cannot slip between the balusters.

The 4 inches is the clear opening, measured between the faces of two neighboring balusters. It is not the center-to-center spacing. With 1.5 inch balusters, a 4 inch gap puts the centers 5.5 inches apart. The rule also covers the gap between the last baluster and the post, and the space under the bottom rail.

Dividing the rail into equal parts does not guarantee a legal gap. Pick the count first, so the gaps come in under 4 inches, then spread the balusters evenly.

End gap 3.40 inGap 3.40 inCenter to center 4.90 inRail length 72 in, post face to post face
The 6 ft example drawn to scale along the rail: 14 balusters and 15 equal gaps. The 4 inch limit applies to the gap, not the center-to-center spacing.

Guard rules that shape the layout

The sphere rule is one of several IRC guard requirements. The section numbers below are from the 2018 and 2021 editions. The 2024 edition moved the guard rules to R321.1.1 through R321.1.3 and kept the same values. Your building department enforces the edition it adopted, with any local amendments, so confirm these numbers before you build.

RequirementIRC valueSection
Guard requiredwalking surface more than 30 in above the floor or ground below, at any point within 36 in of the edgeR312.1.1
Guard height36 in minimumR312.1.2
Stair guard height34 in minimum, from the tread nosing lineR312.1.2
Openingsmust stop a 4 in sphereR312.1.3
Openings on the open side of a stairmust stop a 4-3/8 in sphereR312.1.3
Triangle at tread, riser, and bottom railmust stop a 6 in sphereR312.1.3
Top rail load200 lb at any point along the topTable R301.5
Baluster and infill load50 lb over 1 sq ftTable R301.5

How the spacing works

  1. 01

    Measure between the post faces

    The balusters fill the clear opening from one post face to the other. Do not measure post center to post center.

  2. 02

    Find the count

    Divide the rail length by one baluster width plus the 4 inch max gap, and round up. That count always brings the even gap in at or under 4 inches. It is a safe count and not always the lowest one that passes.

  3. 03

    Find the open space

    Multiply the count by the baluster width and subtract it from the rail length. What is left is the open space the gaps share.

  4. 04

    Split it into even gaps

    Divide the open space by the count plus one. A rail with 14 balusters has 15 gaps, because the gap at each post counts. The result is at or under 4 inches every time.

  5. 05

    Add the width for center to center

    The gap plus one baluster width is the center-to-center spacing, which is the number you step off along the rail.

A worked example

A 6 ft (72 in) rail between posts, in 1.5 in square balusters. The table shows the count, the gap, and where each number comes from.

Rail length72 ingiven (post face to post face)
Baluster width1.5 ingiven (1.5 in square)
Balusters1472 / (1.5 + 4), rounded up
Even gap3.40 in(72 - count x 1.5) / (count + 1)
Center to center4.90 ingap + baluster width

Marking the rail

Hook the tape on the face of the first post and mark every baluster from that end. The near edge of the first baluster sits one gap from the post. Each one after it is 4.90 in further along. These are the marks for the 6 ft example, rounded to the nearest 1/16.

BalusterNear edgeOn the tape
13.40 in3-3/8 in
28.30 in8-5/16 in
313.20 in13-3/16 in
14 (last)67.10 in67-1/8 in

A spacer block is faster than a tape, but its error stacks up. The 3.40 in gap is not a mark on a tape, so the block gets cut to 3-3/8 in. Set all 14 balusters off that block from one post and the last gap comes out at 3-3/4 in. That still passes here. On a longer rail, or with a gap closer to 4 inches, the leftover can push the last opening over the limit. Fasten to the tape marks. If you step off a block anyway, measure the last opening before you fasten the final few balusters.

Common rail lengths

Balusters and the even gap for typical rail sections in 1.5 in balusters at the 4 in code limit. As the rail gets longer the gap widens toward 4 inches, then drops when the next baluster is added.

Rail lengthBalustersEven gap
36 in (3 ft)73.19 in
48 in (4 ft)93.45 in
60 in (5 ft)113.63 in
72 in (6 ft)143.40 in
96 in (8 ft)183.63 in

Count by baluster width

The same 6 ft rail in four common baluster sizes at the 4 in limit. A thinner baluster covers less of the rail, so the count holds or goes up as the width drops. The math assumes a constant width. For a turned spindle, enter its narrowest width, because that is where the opening is widest.

BalusterBalustersEven gap
3/4 in round metal163.53 in
1-1/4 in square spindle143.63 in
1-1/2 in (2x2 lumber, actual size)143.40 in
1-3/4 in square spindle133.52 in

Deck railing calculator: posts and balusters

Enter the deck size, which sides meet the house, and the max post spacing. The calculator splits each railing run into equal sections, counts the posts with the corners shared, and spaces the balusters in every section to the same gap rule. It is the layout the CutOnce deck calculator produces.

Enter the deck the way your tape reads: 16 ft, 12 ft 6 in. Railing runs on every side not attached to the house. Leave the stair opening blank if the stairs come off somewhere else.

Posts8
Balusters81

Railing length 40 ft

RunLengthSectionsBetween postsBalusters eachOn centerGap
112 ft268-1/2 in125-3/8 in3-7/8 in
216 ft360-1/2 in115-3/16 in3-11/16 in
312 ft268-1/2 in125-3/8 in3-7/8 in

For each run, the section count is the run divided by the max post spacing, rounded up. The first run takes one more post than it has sections. Each run after it shares the corner post with the run before, and a freestanding deck shares the last corner with the first.

The clear span between post faces is the run divided by its sections, minus one post width. Each section gets the fewest balusters that keep every gap at or under the max. The total is balusters per section times sections, added up over the runs. A stair opening adds one newel post and takes out the balusters that would have filled it.

With the same on-center option on, every run is fit to one shared baluster spacing, picked halfway between the tightest and widest runs, so the rail looks the same all the way around.

This layout counts with the app's spacing solver, which finds the fewest balusters that keep every gap at or under the max. A section can come out one baluster lighter than the single-rail count at the top of the page, which rounds up on the rail length alone. Both keep the gap at or under 4 inches.

A worked deck railing example

A 16 by 12 ft deck attached to the house on one long side, with 4x4 posts at 6 ft max spacing and 1-1/2 in balusters at the 4 in gap. Every number below comes from the same code as the railing calculator above.

Railing runs12 + 16 + 12 ftthe three sides away from the house
Railing length40 ftthe runs added up
Sections2 + 3 + 2 = 7each run / 6 ft, rounded up
Posts8sections + 1, corner posts shared
Between posts, short runs68-1/2 inrun / sections - 3-1/2 in post
Between posts, long run60-1/2 inrun / sections - 3-1/2 in post
Balusters per section, short runs12 at a 3-7/8 in gapfewest that keep the gap at or under 4 in
Balusters per section, long run11 at a 3-11/16 in gapfewest that keep the gap at or under 4 in
Total balusters8112 x 2 + 11 x 3 + 12 x 2
With a 4 ft stair opening9 posts, 73 balustersone newel post added, the opening's balusters taken out

Deck rail versus stair rail

On a level deck rail the balusters stand plumb and the gaps are measured along the rail. That is the layout this calculator solves.

On a stair the rail follows the slope and the balusters still stand plumb, so the spacing is laid out level, along the treads. The IRC loosens the opening limit a little on a stair. The open side has to stop a 4-3/8 inch sphere, and the triangle formed by the tread, the riser, and the bottom rail has to stop a 6 inch sphere. A stair guard can be 34 inches high, measured from the line of the tread nosings, where a level guard needs 36.

The CutOnce app lays out stair balusters tread by tread in four modes (evenly spaced, on center, best fit, and limited opening), with a mark for every baluster. It checks them against the same 4 inch gap, which sits inside the stair allowance.

How we verify this math

Layout mistakes to avoid

  • Measuring between post centers

    The balusters fill the opening between post faces. Posts set 6 ft on center with 4x4 posts leave 68-1/2 in of rail to fill, not 72 in.

  • Leaving the end gaps to chance

    The gap from the last baluster to the post is an opening like any other, and it is where spacer error ends up. Check it before you fasten the last few balusters.

  • Setting the bottom rail too high

    The space under the bottom rail has to stop the same 4 inch sphere as the gaps between balusters.

  • Building right at 4 inches

    Wet treated lumber shrinks as it dries, and a twisted 2x2 opens the gap beside it. The even layout usually lands a few tenths of an inch under the limit, which covers that movement. If yours comes out close to 4 inches, add a baluster.

Common questions

How far apart should deck railing posts be?
No more than 6 feet apart is the common limit for wood deck railings. That is the maximum guard post spacing shown in the AWC DCA 6 deck guide. Many composite and aluminum rail systems allow 8 feet when the maker rates them for it. The IRC sets no post spacing of its own, but the finished guard has to hold a 200 pound load at the top (IRC Table R301.5) and stop a 4 inch sphere (R312.1.3).
How many posts do I need for a deck railing?
Divide each railing run by the max post spacing and round up for the sections. The posts come to one more than the total sections, because runs that meet at a corner share the corner post. A 16 by 12 ft deck attached on one long side has 40 feet of railing (12 + 16 + 12) and takes 8 posts at 6 ft spacing. A 4 ft stair opening adds a newel post for 9.
How many balusters do I need for a deck?
Multiply the balusters per section by the sections on each run and add up the runs. The same 16 by 12 ft deck in 1-1/2 in balusters at the 4 inch gap takes 81. The 4 ft stair opening drops it to 73.
How far apart can balusters be?
No more than 4 inches of clear gap, under IRC R312.1.3 (R321.1.3 in the 2024 edition). That is the open space between balusters, measured so a 4 inch sphere cannot pass. It applies to required guards on decks, porches, and balconies, which means any edge more than 30 inches above the ground below. The open side of a stair is allowed 4-3/8 inches.
How many balusters do I need for a 6 foot railing?
Fourteen, in 1.5 inch balusters at the 4 inch code gap, spaced about 3.4 inches apart. A 6 foot rail is 72 inches, and 72 divided by (1.5 + 4) is 13.1, which rounds up to 14 so the gap stays legal. Thinner balusters or a tighter target gap raise the count.
Is the 4 inches center to center or the gap?
The gap, which is the clear opening between balusters. Center-to-center spacing is the gap plus one baluster width, so with 1.5 inch balusters a 4 inch gap is 5.5 inches center to center. Marking 1.5 inch balusters at 4 inches on center would leave 2.5 inch gaps and use far more balusters than the rail needs.
Do the end gaps to the posts count?
Yes, and this calculator includes them. The balusters split the rail into one more gap than there are balusters, so a rail with 14 balusters has 15 gaps, counting the two at the posts. Keeping the end gaps equal to the gaps in the middle is what makes the run look even.
What if I want a tighter look than the code allows?
Set a smaller max gap and the count goes up. The 4 inch rule is a maximum, not a target. Plenty of builders run 3 or 3.5 inches, especially with thin metal balusters. Enter your target gap and the calculator sizes the count to stay under it.
How tall does a deck railing have to be?
At least 36 inches, measured from the deck surface to the top of the guard (IRC R312.1.2). A guard along a stair can be 34 inches, measured from the line of the tread nosings. Some jurisdictions amend the height to 42 inches, which is also the commercial height under the IBC, so check locally.
Does a low deck need a railing?
The IRC requires a guard where the deck surface is more than 30 inches above the ground below, measured at any point within 36 inches of the edge (R312.1.1). A lower deck does not need one. If you add a railing anyway, spacing it to the 4 inch rule is still the safe choice around children.
What size are deck balusters?
Wood deck balusters are usually 2x2 lumber, which measures 1.5 inches square. Round metal balusters are commonly 3/4 inch. Enter the actual width, not the nominal size, because the count depends on it. A 6 ft rail takes 14 balusters at 1.5 inches and 16 at 3/4 inch.
Is a spindle the same as a baluster?
For layout, yes. Spindle is the common name for a turned or slender baluster, and picket is used the same way on deck rails. The spacing rule and the math are the same for all three.
What is the baluster gap in millimeters?
The IRC's 4 inches is 101.6 mm. Codes written in metric use their own number. Canada's National Building Code and England's Approved Document K use a 100 mm sphere, and Australia's National Construction Code uses 125 mm. This calculator works in inches, so divide millimeters by 25.4 and set the max gap to match your code. A max gap of 3.93 in keeps the opening under 100 mm.

Space the rail, frame the whole thing

CutOnce spaces the balusters like this page, on level rails and up raking stairs, and it frames the rest: the deck, the stringers, the posts, with a printable rail elevation showing every baluster placed.

Free to download, with a 7-day trial of everything. The web calculator is the teaser; the app draws the rail.

App StoreGoogle Play

See also