Pol Lt Chainaret Suporn, a duty officer at Samut Prakan police station, said the explosion happened about 4.50am. The factory, operated by Wongpasit Printing Co Ltd, is located on Tai Ban Road in Samut Prakan's Muang district.
The injured were admitted to Samut Prakan Hospital. Most of them were workers from Myanmar.
The blast destroyed about 10 wooden houses behind the factory.
Four fire engines were deployed to put out the fire.
Police suspect that the boiler exploded because there was not enough water in it. The cost of the damage is estimated to be over one million baht, police said.
Prajak Makaew, a 38-year-old factory worker, said he heard a loud explosion while working on a night shift inside the factory building.
"I ran to see what happened and I saw the large boiler fall to the floor. The roof was blown off and flames spread everywhere," Mr Prajak said.
Wachara Narapakdikul, the operator of the dyeing factory, said she had rented the facility. She agreed to take responsibility for the injured people and all the damage.
A boiler at a cloth dyeing factory in Samut Prakan exploded early Sunday, injuring at least 21 people and damaging many houses nearby. (Video by Pattarapong Chatpattarasill. Photos by Sutthiwit Chayutvoraken and Thiti Wannamontha)