Railing Calculator
Calculate balusters, posts, and rails for deck or stair railing from run length and baluster spacing.
Returns a full materials list and code-compliant count.
Deck and stair railings must meet building codes in almost every jurisdiction, so working out the materials before you buy saves money and keeps the finished rail legal. The three numbers that drive everything are the total linear footage of railing, how far apart the posts sit, and the gap you want between balusters.
Key formulas:
Number of Posts = (Total Linear Feet ÷ Post Spacing) + 1 Balusters per Section = ⌈(Section Width − Gap) ÷ (Baluster Width + Gap)⌉ Top Rail Length = Total Linear Feet (plus 10% for waste and cuts)
That second formula is the one people get wrong. Dividing the section width by the gap alone pretends the balusters have no thickness, and it over-counts badly. With n balusters in a section there are n + 1 gaps, so the real spacing unit is one baluster plus one gap. For a 1.5-inch square baluster and a 4-inch gap, that unit is 5.5 inches, not 4.
What each variable means:
- Post Spacing — typically 6 to 8 feet on center for wood, 4 to 6 feet for aluminum.
- Baluster Gap — most codes cap the clear gap at 4 inches, meaning a 4-inch sphere must not pass through. The calculator rounds the count up so the finished gap always lands under your target.
- Rail Height — a guard is required once the walking surface sits more than 30 inches above grade. The International Residential Code (IRC) sets 36 inches minimum for houses. The International Building Code (IBC) sets 42 inches for commercial work, and a few states apply 42 inches to homes as well, so check locally before you cut posts.
Worked example: A deck has 40 linear feet of railing. Posts every 8 feet, 1.5-inch balusters, 4-inch maximum gap.
Posts = (40 ÷ 8) + 1 = 6 posts, giving 5 sections of 96 inches Balusters per section = ⌈(96 − 4) ÷ (1.5 + 4)⌉ = ⌈16.7⌉ = 17 Total = 17 × 5 = 85 balusters, and the finished gap is (96 − 25.5) ÷ 18 = 3.92 inches Top rail = 40 × 1.10 = 44 linear feet (with waste)
Typical material quantities:
- A 20-foot deck split into three sections by 8-foot post spacing takes about 51 balusters at 4-inch gaps. Divide by the gap alone and you get 60, which is where most over-orders come from.
- Add 5 to 10% waste for angle cuts on stair sections.
How we build and check this calculator
This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.
SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.