An explosion and raging fire at a fireworks factory near the Indonesian capital has killed at least 47 people and injured dozens, according to AFP news agency.

"In total 47 people died. We don't know for sure the number of people who are still unaccounted for," Harry Kurniawan, Tangerang Kota police chief, told Kompas TV.

The fire began on Thursday morning at the factory located in a warehouse complex in Tangerang, a city in Banten province on the western outskirts of Jakarta.

A police report said the fire spread after an explosion and that the factory's roof had collapsed.

Kurniawan said dozens of injured people were being treated at three hospitals. The factory had been operating for less than two months, he said.

A Jakarta police official, Nico Afinda, told Associated Press that the bodies were found piled at the rear of the building. The factory had more than 100 employees, according to Afinda.