According to Decks Online, the International Residential Code requires decks attached to single family detached homes have guardrails at least 36 inches tall. The IRC requires commercial decks attached to apartment buildings or businesses to have guardrails that are 42 inches tall.
Local Building Codes May Differ
According to Deck Design, local building codes may require guardrails of different heights depending on the type of structure to which the deck is attached. It notes "The height of a deck railing is usually between 30 and 40 inches, but this can be subject to various restrictions."
Deck Design recommends checking your local building codes prior to building a deck or replacing its railing. These codes also frequently specify baluster spacing as well as deck to bottom rail spacing, so they are worth familiarising yourself with prior to building.