The International Residential Code, the building code on which most local building codes are based, requires that habitable residential rooms must be a minimum of 70 square feet. Bathrooms, however, are exempt from that requirement, allowing for truly tiny half bathrooms. The IRC does specify minimum clearances for bathroom fixtures, and those requirements determine the minimum acceptable dimensions for a half bathroom.
The IRC requires that there be 15 inches of clear space from the center line of the toilet to the closest wall on each side, so the minimum side-to-side dimension for the space enclosing the toilet is 30 inches. The IRC also mandates that there be 21 inches of clear space between the front of the toilet bowl and a wall or any other fixture, so the minimum front-to-back dimension for the space containing the toilet is the depth of the toilet plus 21 inches.
Video of the Day
A sink or vanity must also have 21 inches of clear space in front of it to accommodate someone standing at the sink, but that space can overlap with other required spaces. That means, for example, that you could mount the sink directly opposite the toilet with 21 inches between them and satisfy the clear-space requirements for both the toilet and the sink. There are no side-to-side space requirements for sinks.
A swinging door that swings into the bathroom requires, of course, enough clear space in the room for it to swing freely and completely. A pocket door, which slides horizontally into the wall when open, removes the need for clear space for the door in the room itself. The minimum wall length for a pocket door is essentially twice the width of the door, enough for the door opening and adequate wall space for the door to open fully.
Bathrooms are not exempt from the ceiling-height requirements for habitable spaces. All habitable residential spaces, including bathrooms, must have a minimum ceiling height of 7 feet. If the ceiling is sloped, at least half of the room's floor area must have a ceiling height of at least 7 feet, and no part of the ceiling can be less than 5 feet high. In addition, half bathrooms must have a minimum ceiling height of 6 feet 8 inches in the center of the clear space in front of the toilet and sink.