Build Deck Railing That Passes Code and Lasts

Railing changes everything about how a deck functions. Without it, you've got a platform. With it, you've got an outdoor room where people relax instead of worry about edges. The work sits at the intersection of precision carpentry and building code—posts must be rock-solid, spacing must meet local requirements, and the finished product needs to look intentional, not improvised. Most jurisdictions require railing on any deck more than 30 inches above grade, with balusters spaced so a 4-inch sphere can't pass through. Posts anchor the system, top and bottom rails create the frame, and balusters fill the gaps. The materials matter less than the math and the fastening. Get the layout right, use proper hardware, and the railing will outlast the deck boards beneath it. Rush the measurements or skip structural screws, and you'll feel the wobble every time someone leans against it.

  1. Check Your Backing First. Measure and mark post positions every 4 to 6 feet around the deck perimeter, starting and ending at corners. If your deck already has rim joists with blocking, verify they're solid enough to accept lag bolts or through-bolts. For decks without adequate backing, you'll need to sister additional blocking between joists before setting posts.
  2. Anchor Posts Solid. Mount each post using code-approved brackets or through-bolts, not deck screws alone. For surface-mount brackets, use lag bolts into rim joists with blocking behind. For through-bolt installations, drill through the rim and secure with washers and nuts on the inside. Plumb each post with a level and temporarily brace before final tightening.
  3. Cut Consistently Level. Measure 36 to 42 inches from the deck surface, depending on your local code, and mark all posts. Use a laser level or water level to ensure consistent height across the entire run. Cut posts with a miter saw or circular saw, leaving the top cut square for clean cap installation later.
  4. Set Top Rail Level. Rip 2x6 or 2x4 material for the top rail, depending on your design. Set the rail flat on top of the posts or notch it into the post faces for a cleaner look. Secure with two 3-inch structural screws at each post connection, pre-drilling to prevent splitting. Keep the top edge dead level across spans.
  5. Parallel Rails Rule. Position the bottom rail 2 to 4 inches above the deck surface, keeping it parallel to the top rail. This gap prevents debris accumulation and simplifies sweeping. Fasten to the inside face of each post with structural screws, checking for twist as you go—bottom rail warp telegraphs through every baluster.
  6. Math Beats Eyeballing. Measure the distance between posts and divide by baluster width plus maximum gap allowed by code—typically 3.5 inches on-center for 2x2 balusters. Mark both top and bottom rails simultaneously using a spacer block cut to exact width. Work from both ends toward the center, adjusting the middle gap slightly if needed to avoid awkward partial spacing.
  7. Space and Plumb Every One. Cut all balusters to length at once for consistency. Install each baluster plumb, fastening with two screws at the top rail and two at the bottom. Alternate which face you screw into if using dimensional lumber to distribute any cupping or twisting. Work methodically across each section, checking plumb every fifth baluster.
  8. Cap It Off Right. Install post caps with construction adhesive and one finish nail or screw through the top center. These shed water and finish the look. Check all fasteners for tightness, inspect joints for gaps, and apply exterior wood filler to any visible screw holes or imperfections. Seal cut ends with additional preservative if desired.