BANGKOK — An explosion and blaze at a fireworks factory killed at least 47 people and injured dozens on Thursday near Jakarta, the Indonesian capital, the authorities said.

The fire sent huge plumes of dense black smoke billowing above Tangerang, a city of about two million people just west of Jakarta.

About 100 people worked at the PT Panca Buan Cahyadi factory, and many apparently were trapped inside on Thursday morning, unable to escape. Some of the victims were burned beyond recognition, officials said.

In addition to the dead, at least 46 people, some with serious burns, were taken to hospitals, the police said.