There are international and state-based regulations for legal requirements of a stair railing height. Before installing or replacing a hand rail in your home, familiarise yourself with the legal codes associated with residential building regulations.
International Residential Code (IRC)
The International Residential Code is a comprehensive building code that outlines minimum regulations for or one- and two-family dwellings of three stories or less. According to Section R322.214.171.124, handrails must be no less than 34 inches and no more than 38 inches, above the nosing of the tread.
State Building Code
The requirements for handrail height range from state to state. Since local codes vary, contact your local building department for information regarding regulations that apply to your area.
If you want to be sure and be "legal" in your area, check with the local building inspector.
Remember to take the height measurement from the end of the stair tread.