An accidental fire at a first-floor flat in Tring is thought to have been started by a cigarette.
The people living inside the block above shops on Miswell Lane had escaped the flames before firefighters arrived.
Crews from Tring, Hemel Hempstead, Berkhamsted and Aylesbury attended the scene after being called at 2.01am.
Crew commander Daniel Blackburn said four jets were needed to put out the fire, which caused extensive damage to the two-storey building and had also broken through the roof.
It was dealt with by 5.35am. It is thought the building will be uninhabitable for a period of time.