How to Build a Deck Railing

Building a deck railing is one of those projects that looks complicated until you break it down. The work is really just three layers: vertical posts that anchor to your deck, horizontal rails that connect those posts, and the infill—balusters, pickets, or panels—that fills the space and keeps someone from falling through. Code will tell you what spacing you need and how tall it has to be, but the actual carpentry is honest and forgiving. You'll see the structure as you build it, which means mistakes are visible and fixable before you're done. Most people finish this in a weekend, and the railing is what makes a deck feel intentional rather than unsafe. The key decision upfront is material: pressure-treated lumber is affordable and solid, composite materials cost more but need almost no maintenance, and aluminum systems run faster to install but require precision. Whichever you choose, the process is identical—measure, cut, bolt or screw, and move forward. Code requires railings on decks 30 inches or higher, and the rules are specific about post spacing, baluster gaps, and top-rail height. Check your local building department before you start; a quick call takes five minutes and keeps you out of trouble.

  1. Measure and mark post locations. Walk your deck perimeter and mark where posts will go. Posts must be no more than 6 feet apart; 4–5 feet is stronger and looks better. Mark centerlines on the deck rim where each post will sit. Use a tape and a square to make sure marks are plumb and square to the deck edge.
  2. Drill pilot holes and bolt posts to the rim. Drill ½-inch pilot holes through the rim at your marked locations, angling slightly upward so water runs out. Slide lag bolts or carriage bolts through the post base (typically a metal bracket bolted to a 4x4 post) and tighten them hand-tight with a wrench. Do not overtighten; you'll crack the rim. The post should feel solid but not locked.
  3. Set and brace posts plumb. Use a 4-foot level on two adjacent sides of each post to confirm it's plumb. Tack temporary diagonal braces from the post to the deck joists with 2½-inch screws. These hold the post upright while you work. Do not remove braces until top rails are fully fastened.
  4. Cut and install top and bottom rails. Measure the distance between post faces. Subtract ½ inch for clearance and cut your top and bottom rails to length. Pressure-treated 2x4 is standard; composite 2x4s go the same way. Bolt or lag the bottom rail about 3 inches up from the deck surface. Bolt the top rail so its top edge is 36–42 inches above the deck (check your code—this is the minimum height). Rails must be level; use shims if the deck rim isn't perfectly straight.
  5. Install balusters or infill panels. If using balusters, lay them out along the rail span first. They must be no more than 4 inches apart (the sphere rule: a 4-inch ball can't pass through). Mark centers on the top and bottom rails, then screw each baluster on with 2½-inch deck screws—two per end, countersunk ½ inch. If using composite or aluminum panels, follow the manufacturer's slot system; they typically slide into routed rails and lock without fasteners. Solid panels go in the same way as balusters but are wider.
  6. Cut and install trim cap or rail cover. A cap board over the top rail protects the end grain and looks finished. Measure the total rail length including corners. Cut your cap stock (typically a 2x6 or specialty trim board) to length with 45-degree miters at outside corners or a simple butt joint at inside corners. Screw the cap down with 2½-inch deck screws every 16 inches, countersunk and filled with paintable filler.
  7. Remove braces and seal the wood. Once the top rail is fully fastened and capped, remove temporary braces. Inspect all fasteners and tighten any that are loose. If you're using pressure-treated lumber, let the wood weather for 3–6 months before staining or sealing; freshly treated wood is too wet. If you're using composite, skip sealant and just clean annually with soap and water.
  8. Final inspection and adjustments. Walk the railing, lean on it, and test for movement. Posts should not rock. Balusters should not rattle. If any fasteners are loose, tighten them. If a post feels soft, you may have hit wet joist wood; inject epoxy consolidant and re-bolt. Check that your 4-inch sphere rule is met along the full length by testing with a ball or flexible measuring device.