Sparks from the generator made contact with chemicals used to make the shoes, igniting the blaze.
Pakistan faces widespread blackouts, and many people use generators to provide electricity for their houses or to run businesses.
One of the workers, Muhammad Shabbir, said he had been working at the factory for six months along with his cousin.
He said all the chemicals and the generator were located in the garage, which was also the only way out of the building.