"In total 47 people died".
The Tangerang police chief, Harry Kurniawan, said the police were investigating whether the factory had been properly licensed to manufacture fireworks.
Bodies were taken to hospital to be identified but most were burned beyond recognition.
Parts of the building collapsed after being gutted by the blaze which scorched nearby cars.
Witnesses said they heard a huge blast, followed by smaller ones which echoed across the neighbourhood in Tangerang.
"I saw people including women were jumping from above".More news: Amazon announces Alexa powered security camera along with a new delivery service
The fire has been brought under control.
Authorities said the fire spread quickly after starting near the front door. "We are going to search whether there are any victims that need immediate treatment at hospitals". Yuwono said an emergency exit had been locked, preventing workers from escaping, and many charred remains were found in a pile.
"I don't know how it happened, I was working outside of the factory and there were some explosions, four cars exploded and nearly all motorbikes also exploded", Ade, who suffered burns to his arms and legs, told AFP.
A police official says 39 people have been killed in an inferno at a firecracker factory outside the Indonesian capital Jakarta.
Media images of the PT Panca Buana Cahaya Sukses warehouse showed smoldering ashes and debris.
Seventeen people killed when a fire ripped through a karaoke bar on Sulawesi island in 2015.