Tokyo is
huge. It's actually less dense than San Francisco. There's a lot of room to build out, and the train system makes that possible.
It's unlikely a janitor would be able to afford a comfortable apartment 20 minutes from work. The norm in Japan is for the husband to be the sole breadwinner, and a janitor's salary would almost certainly push them further away from the center. You certainly can live in the center parts of the city, with low prices, but the place you rent is not going to be comfortable. This is a better situation than SF or NYC, obviously.
Tokyo is actually quite expensive. You can't compare the specific prices against American cities, because the wages are considerably lower. Folks work insane hours to get overtime pay to afford their lifestyles. Similarly, the reason the prices don't increase is partially because they keep up with building enough units (and that's partially due to zoning), but also because there's effectively no inflation, and there hasn't been inflation for a long time. Prices don't change, but neither do wages. Home prices are also deflationary, unlike the US.
Tokyo is a great city to use as a good example of building a dense, immensely enjoyable city, but it's best not to exaggerate.
(I currently live in Tokyo and am in the process of buying a home)