If your deck is 30 inches or more above the ground, you should install a railing around the deck. Check local building codes before making a final decision on whether or not to install railings, since some communities may require railings for decks as little as 18 inches above the ground. In some areas, the Fire Marshal regulates issues like this. Many manufacturers of prefabricated railing systems build the systems to comply with IRC requirements. If you build your own railing system, follow the IRC and local code requirements.
The top rail of the railing system must be at least 36 inches above the surface of the deck. If the deck is attached to a commercial building, the deck railing must be at least 42 inches above the deck surface. A deck with built-in seating that forms all or part of the deck enclosure must still comply with the 36- or 42-inch rule, but measured from the seat. For example, if one side or portion of a side of the deck includes a built-in bench, the railing behind the bench must measure 36 or 42 inches high from the height of the bench seat. You can either place the railing behind the seat or build a seat with a back tall enough to meet the height requirements.
Height requirements also apply to railings for any stairs attached to the deck. Stairs less than 43 inches wide require one handrail, and stairs wider than 43 inches require a handrail on each side. Generally, only stairs with four or more risers require a handrail. The handrails must be a minimum of 32 inches above the outside edge of each stair, but no higher than 36 inches. The railings must be at least 36 inches above the surface of any stair landings. Be sure the handrail is easily gripped for support. The top rail should be 1 1/4 to 2 inches across if the top rail is round. If the top rail is square, it should be no more than 2.25 inches across, measured diagonally.
Balusters, spindles, glass panels, latticework and other materials may form the "wall" of the deck and stair railings. Regardless of what material is used, the vertical elements may not have gaps large enough for a sphere 4 inches in diameter to pass through it. This includes any space or gaps between the seats of benches and the floor of the deck. If you have built-in seating, the space under the seating can't be open, since small children may be able to crawl beneath the seat and fall off the deck.
In addition to checking with your local code enforcement division about specific differences in local codes and the IBC-based state codes, make sure your neighborhood does not have restrictive covenants. Find out if the deck could violate any easements or setback requirements. If you install railings with glass panels, the glass must be made of tempered safety glass.
Some communities do not insist on inspections, while others may demand both a detailed construction plan and a formal inspection. Your local building inspector may be willing to inspect the railing for possible safety issues even if no inspections are required.