A further 700 were left injured, according to Major General Suharyanto, head of the BNPB.
The quake hit the Cianjur region in West Java province at a depth of 10 kilometers (6.2 miles), according to the United States Geological Survey (USGS).
Four schools and 52 houses collapsed or were badly damaged, according the BNPB local office in the Cianjur region. A mosque and a hospital were also damaged, according to the office.
The BNPB said there is no risk of a tsunami, Reuters reported.
Herman Suherman, a government official in Cianjur, told media that some residents were trapped in the rubble of collapsed buildings. News channel Metro TV showed what appeared to be hundreds of victims being treated in a hospital parking lot.
It said that an Islamic boarding school was also damaged, while communications had been disrupted due to power outages.
TV footage showed residents huddled outside buildings almost entirely reduced to rubble, according to Reuters.
One, named only as Muchlis, said he felt “a huge tremor” and the walls and ceiling of his office were damaged.
“I was very shocked. I worried there would be another quake,” Muchlis told Metro TV.
The BMKG said warned of a danger of landslides, particularly in the event of heavy rain, as 25 aftershocks were recorded in the two hours after the quake.
Indonesia sits on the “Ring of Fire,” a band around the Pacific Ocean that sets off frequent earthquakes and volcanic activity. One of the most seismically active zones on the planet, it stretches from Japan and Indonesia on one side of the Pacific all the way across to California and South America on the other.
In 2004, a 9.1 magnitude quake off Sumatra island in northern Indonesia triggered a tsunami that struck 14 countries, killing 226,000 people along the Indian Ocean coastline, more than half of them in Indonesia.