All of the victims were employees of the fireworks factory in Tangerang, just south-west of Jakarta, local fire department official Oni Sahroni told Metro TV.
The initial explosion blew off the factory's roof, local police said in a statement.
The bodies of the victims were charred beyond recognition, it said.
Footage taken by a local using a mobile phone showed flames engulfing the factory while residents shouted "Oh God! oh God!"
The factory, run by PT Panca Buana Cahaya Sukses, had operated for only six weeks, district chief Toni Rustoni said.