Deck Railing Spacing Calculator
Give this calculator the clear run between your posts and it returns the layout — how many balusters, the exact clear gap, and the mark for every one measured from the same post face. Most calculators return a spacing. A spacing divides evenly on paper and leaves a different gap at the far post, which is the one an inspector looks at.
Your guard
Results update as you type
- Gap: 3 ⅞" clear
- Sphere: 4" (R312.1.3)
- Clear gap, every one 3 ⅞"Face to face between two balusters, and between each post and the baluster beside it. Exactly 3.846 in; mark it at 3 ⅞".
- Centre to centre 5 ⅜"The gap plus one baluster. Useful for checking your marks; it is not the number the sphere rule is about.
- Inside the sphere by ⅛"The 4" sphere for this section is R312.1.3. Anything at or over it passes, so the gap has to come in under.
- Inside the limit: Openings in the guard Must not pass a 4" sphere 13 equal gaps of 3 ⅞" clear — ⅛" inside the sphere. The two gaps at the posts are counted, because an opening beside a post is an opening. IRC R312 — Guards
- Inside the limit: Guard height 36" minimum from the deck walking surface 36" measured from the deck walking surface. IRC R312 — Guards
- Worth knowing: Clear gap, not on centre Not a code limit — an arithmetic one Every gap above is clear space between two baluster faces. Read 5 ⅜" as an on-centre spacing instead and the gap falls to 2 ½", which needs 17 balusters in this run rather than 12. Established deck-building trade practice
A 68" (1.73 m) run takes 12 balusters, not 17. 17 is what you get by dividing the run by the 4" sphere. It is also what you get by reading a 5 ⅜" on-centre spacing as though it were a gap. Two different wrong roads, the same wrong answer, and the same reason: the sphere is a limit the gap has to clear, not a spacing to build to.
12 is what passes — 3 ⅞" clear, ⅛" inside the limit, spread evenly across 13 openings, because the space between each post and the baluster beside it is an opening in the guard too.
Switch to a stair section and three separate provisions apply where one did: a 4 ⅜" sphere for the infill (R312.1.3 exception), a 6" sphere for the triangle at the tread and the bottom rail (R312.1.3 exception), and a guard height measured from the nosing line rather than from a surface (R312.1.2). All from the 2021 IRC, which your jurisdiction adopts an edition of and amends. Change any input above and the panel updates.
A spacing is not a layout
A spacing tells you how far apart to put two balusters. It does not tell you where to put the first one, and that is the whole problem. Start at one post, step off 5 ⅜" at a time, and you arrive at the far post with whatever is left — a gap that matches none of the others and is the first thing anyone looks at.
This calculator runs the arithmetic backwards. It counts the openings rather than the balusters: 12 balusters in a run make 13 openings, every one the same width, and that width is the run less the balusters, divided between them. Raise the count by one and every gap narrows. The first count whose gaps come in under the sphere is the answer, and it is the smallest one that works — at 68", 11 balusters would leave 4 5/16", which the sphere passes.
Then it gives the marks. Every centre is measured from the same post face — 4 ⅝" for the first, 9 15/16" for the second, on to 63 ⅜" for the last. Measuring each baluster from the one before it is how a run picks up a sixteenth of an inch at every step and finishes visibly wrong at the far end. One tape, one datum, 12 marks.
Clear gap, not on centre
Two numbers describe the same railing and they are not interchangeable. On centre is measured baluster centre to baluster centre. Clear is the air between them — the gap a 4" sphere has to fail to pass.
At the default run those are 5 ⅜" and 3 ⅞". Both correct, 1 ½" apart, and only one of them is the one the code measures.
The expensive version of the mistake is reading the on-centre figure as a gap. Space 1 ½" balusters at 4" on centre and the air between them is 2 ½" — legal, and 42% more balusters than the run needs. 17 where 12 pass, and every one of them bought, cut, drilled and finished.
Ask which number you are holding before you cut anything. If it came off a spacing, it is on centre. If it came off the code, it is clear.
The gaps at the posts count
The space between a post and the baluster beside it is an opening in the guard, and the 4" sphere (R312.1.3) applies to it exactly as it applies to the middle of the run. A 68" run with 12 balusters has 13 openings, not 11.
Leaving the two end gaps out of the arithmetic is the most common way a layout that measured right on paper fails at the post. It also fails where it is easiest to see: a wide gap in the middle of a run reads as spacing, and a wide gap against a post reads as a mistake.
The stair rake is three rules, not one rule with variants
Switch a section to the open side of the stairs and three separate provisions apply. The infill openings are measured against a 4 ⅜" sphere rather than 4" (R312.1.3 exception). The triangle at the foot of each baluster gets 6" of its own (R312.1.3 exception). And the guard height is measured from a line through the tread nosings rather than from a walking surface (R312.1.2). Three constants, because three provisions.
On this flight the same 68" run takes 11 balusters raked where it takes 12 level, at 4 5/16" clear against 3 ⅞".
The opening on a rake is measured horizontally, and the common claim that it is measured perpendicular to the rail is wrong for the railing most people build. Balusters go in plumb. Two plumb balusters present parallel vertical faces, and the shortest distance between two parallel vertical planes is horizontal whatever the rail above them is doing — a sphere simply slides along the rake until it finds the narrowest point, which is the horizontal one. The claim is true for balusters set perpendicular to the rail, and that is a different railing.
What the rake does change is where the marks go. Mark on the rail, not on the deck. The rail is longer than the ground beneath it, so the same balusters that sit 5 13/16" apart horizontally land 6 ¾" apart measured along the rail. Step off the horizontal figure with a tape held against the raked rail and every baluster lands short, the error accumulating down the flight.
The riser and tread depth the rake is worked from are the two numbers the deck stairs calculator returns. Take them off that page rather than measuring an angle with a protractor — this flight rakes at 30.7°, and both pages arrive at that figure from the same two dimensions.
The triangle at the bottom of a stair guard
Where the bottom rail crosses a step, the tread, the riser above it and the underside of the rail enclose a triangle. It is an opening, it has its own sphere — 6", R312.1.3 exception — and almost nothing checks it.
A sphere passes a triangle when its diameter fits the largest circle you can draw inside it, which for a right triangle is the two legs less the hypotenuse. The triangle here is the step triangle scaled by how far the bottom rail sits above the line through the nosings, so every inch the rail rises scales the opening with it.
With the bottom rail on the nosing line this flight passes 4 ⅜" — comfortably inside. Raise the rail 3" and the opening reaches 6 9/16", which fails. The calculator returns the point it turns: 2 ¼" above the nosings on this flight, and it recomputes when the riser or tread changes.
Running the bottom rail down on the nosing line is common precisely because it keeps this triangle at its smallest. If the rail has to sit higher, the opening is what closes it — an extra baluster does nothing, because the triangle is bounded by the rail and the step rather than by the infill.
Two runs of different lengths will have different gaps
A deck has several sections between several posts and they are rarely the same length. Lay each one out on its own and the gaps come out different. A 68" run gives 3 ⅞" clear; a 92" run gives 3 11/16". Both pass. They differ by ⅛", and the place you will notice is the corner where the two meet.
Lay out each section independently anyway. Forcing a matched gap across sections of different lengths means adding balusters to one of them for appearance, which costs material and buys nothing the code asks for.
If the difference is visually obvious, the fix is post positions, not baluster spacing. Equal openings between posts give equal gaps everywhere. Post positions are decided when the deck frame goes in, though, not when the railing does — so on an existing deck this is worth knowing and not worth acting on.
The alternative is to accept it, which most decks do. An eighth of an inch across a corner is not something anyone sees without two tapes and a reason to look.
Which guard height applies, and what it is measured from
A guard on the deck is at least 36" measured from the walking surface (R312.1.2). A guard on the open side of the stairs is at least 34" measured from a line through the tread nosings (R312.1.2). Same section of the code, two different datums.
The datum is what goes wrong. Measure a stair guard from a tread surface instead of from the nosing line and it reads tall by most of a riser, which is enough to build a guard that measures fine on your tape and short on the inspector's. The calculator asks which section you are laying out and checks against the matching datum rather than against a single number.
Guard height and handrail height are separate requirements that happen to share a number on the stairs. The deck stairs calculator holds the handrail — when it is required, how high, and what graspable means.
What this calculator will not tell you
It lays out infill. Three things decide whether that guard stays where you put it, and it answers none of them:
- How far apart the posts may sit. A guard has to take a load, that load goes into the posts, and how far apart they can be depends on the post and its connection. That is a strength question and this site does not answer strength questions.
- How the guard is fixed to them. The connection is where guards fail, and it is hardware and fastening rather than geometry.
- Whether the infill itself is strong enough. This is the one most easily missed, because spacing looks like the whole requirement and it is not: the code asks the balusters and their connections to resist a load pushed horizontally against them, quite separately from the load on the top rail. A run can be spaced perfectly and still be fixed too lightly. We lay out the gaps; we do not check what holds them there, and no calculator on this site does.
- Cable and glass infill. Both have their own rules and their own hardware, and neither is laid out like a baluster run.
The baluster width the calculator starts with is the dressed width of a 2x2 — 1 ½", not two inches. Type your own if you are using something else; the field takes any width rather than offering a list of products whose dimensions this site cannot cite. The 5" figures and stock sizes on the stairs page are the same kind of thing, and are labelled the same way.
Common questions
How far apart should deck balusters be?
Close enough that no gap passes a 4" sphere (IRC R312.1.3), which on a 68" run means 12 balusters at 3 ⅞" clear. There is no single right spacing, because it depends on your run and your baluster width. What is fixed is the sphere, and the gap has to come in under it rather than land on it.
How many balusters do I need for a 7.7 ft railing?
17 in a single 92" clear run, at 3 11/16" clear. Count the opening between each pair of posts separately rather than the whole railing at once — a railing is several runs, and each one gets its own layout. Add the runs together afterwards for a shopping total.
Is baluster spacing measured on centre or clear?
Clear. The sphere rule is about the opening, so it is the air between two baluster faces that counts. At the default run the clear gap is 3 ⅞" and the on-centre figure is 5 ⅜" — both correct, 1 ½" apart, and only one of them is what the code measures.
How do I space balusters on stair railings?
Mark the centres along the raked rail, not across the deck. The same 11 balusters that sit 5 13/16" apart horizontally land 6 ¾" apart measured along the rail, because the rail is longer than the ground beneath it. The clear gap between two plumb balusters stays horizontal at 4 5/16".
Why is stair baluster spacing different from a level run?
Because a different sphere applies: 4 ⅜" on the open side of stairs (IRC R312.1.3 exception) against 4" on the level (R312.1.3). The same run takes 11 balusters raked where it takes 12 level. Two more provisions apply on a stair as well — the triangle at the bottom, and a guard height measured from the nosing line.
What is the triangle rule at the bottom of a stair railing?
The opening formed by the tread, the riser and the bottom rail must not pass a 6" sphere (IRC R312.1.3 exception). It grows as the bottom rail rises: on this flight it is 4 ⅜" with the rail on the nosing line and 6 9/16" with it 3" above them, which fails. The calculator returns the maximum — 2 ¼".
Do the gaps at the posts count?
Yes. The space between a post and the baluster beside it is an opening in the guard like any other. A 68" run with 12 balusters has 13 openings, not 11. Leaving the end gaps out of the arithmetic is how a run that measured right on paper fails at the post.
What is the formula for baluster spacing?
Clear gap = (run − N × baluster width) ÷ (N + 1), where N is the baluster count and N + 1 is the number of openings. The search runs backwards from it: raise N until the gap falls under the sphere. At 68" with 1 ½" balusters, N = 12 gives 3.846 in and N = 11 gives 4.292 in, which fails.