The International Residential Code, which regulates decks attached to single family homes, requires they have guardrails at least 36 inches in height from the deck floor to the top of the rail. Decks attached to commercial or apartment buildings must have railings 42 inches high, per the International Building Code.
Any deck that is 30 inches above the surface of the ground must have a guard rail and even if the deck is less than 30 inches above ground, if a railing is added, it must meet IRC and IBC requirements. Codes also regulate the spacing of balusters, which are the columns or spindles of a railing, requiring that the space between balusters must not be wide enough for a 4" diameter sphere to pass between them. If a 4" sphere can pass through, the railing is out of compliance.
IRC and IBC building codes require three tests of all engineered railing systems. Balusters must meet infill load test requirements that a 1-foot square area can resist 125 pounds of force. The uniform load test measures whether or not the top rail can sustain 125 pounds of force applied both horizontally and vertically. The top rail must also pass a concentrated load test showing that it can hold 200 pounds of force at mid-span, on the side of a post and on the top of a post.