All decks higher than 30" above grade must have a guardrail. If you choose to install a guardrail on a deck lower than 30" you must still meet code requirements. Decks attached to single family detached homes are regulated under the rules of the International Residential Code (IRC). The IRC requires guardrails to be at lest 36" in height measured from the deck surface to the top of the rail. Commercial decks attached to multifamily buildings such as apartment buildings or businesses are regulated under the International Building Code (IBC). The IBC requires 42" high guardrails. In either case you are allowed to build taller guardrails as long as they conform to all other requirements stated in the code.
A variety of styles are allowed as long as the interior sections of the rail don’t possess any openings large enough to pass a 4” diameter sphere through.In the case of guardrails for stairs there is an exception that allows up to a 6”diameter sphere through the triangle opening formed by the stair riser, stairtread, and bottom rail.The guardrails must be strong enough to withstand aconcentrated 200 lb force anywhere along the top of the rail.To achieve thisyou should space rail posts no greater than 6' apart. The sweepspace between the deck surface and the bottom rail must be less than 4".
Handrails are required for stairs and must meet standards as specified by R322.214.171.124 in the IRC code.The top edge of the handrail must be placed between 34” and 38” above the nosing of the stair treads. Handrail ends must be returnedand terminated at rail posts.The handgrips must allow a minimum of 1-1/2” spacebetween the handrail and the guardrail or wall. A variety of gripping surfacesmay be acceptable but must meet requirements for gripping surface.Flat 2x4 and 2x6 handrails are not acceptable.A circular cross section of a handrail musthave an outside diameter of between 1-1/4” and 2”.
Engineered railing systems must be tested to meet IRC and IBC building codes. The tests include:
Infill Load Test: The strength of the balusters are tested so that a 1 square foot area must resist 125 lbs of force.
Uniform Load Test: The top rail must be able to sustain 125 lbs of force applied horizontally or vertically.
Concentrated Load Test: The top rail must be capable of holding a point load of 200 lbs of force applied to the mid span, on the side of a post, and on top of a post.
A safety factor of 2.5 is usually added to the testing.
These tests are performed by an accredited third party testing agency.