A six-year-old boy has been pulled from the rubble of a deadly Indonesia earthquake after spending two days trapped under debris without food or water, in a "miracle" rescue.

The dramatic rescue captured on camera revived hopes that survivors could still be pulled alive from the wreckage days after the strong tremor that hit the West Java town of Cianjur on Monday, killing at least 271 people.

"Once we realised Azka was alive everybody broke into tears, including me," a local volunteer said.

"It was very moving, it felt like a miracle."

Video showed rescue workers pulling the boy Azka free from a destroyed home in Cianjur's worst-hit district of Cugenang.

The man who pulled him out of a hole cut in the debris clasped him in both arms, as another rescue worker ran after them to hold the boy's hand, footage released by the administration of West Java's Bogor district showed.

He was only saved by a wall holding up another collapsed wall, preventing it from falling on him, local media reported (Credit: Basarnas/Anadolu Agency)

The boy was then shown calmly sipping a drink, held by a soldier as another emergency worker stroked his hair.

His mother died in the earthquake and her body was found hours before Azka's rescue, a volunteer said.

The boy was then found next to his dead grandmother, volunteers said.

He was only saved by a wall holding up another collapsed wall, preventing it from falling on him, local media reported.

"He was found on the left side of the house, on a bed. He was protected by a pillow and there was a ten-centimetre gap between him and the concrete slab," the volunteer said.

"Such a narrow space, it was dark, hot and there was not enough hole for air.

"We didn't expect him to still be alive after 48 hours, if we knew we would have tried harder the night before.

"For all the years since I became a volunteer, I've never seen anything like this. How can you not cry?"

Many of those killed in the quake were children at school or in their homes when the earthquake struck, officials said.

But authorities warned that time was running out as rescue workers were delayed by hammering rain and potentially deadly aftershocks.

Volunteers rest following a rescue

"Today for the search and rescue operation we deployed 6,000 people. It was raining but we keep searching," said the head of the national disaster mitigation agency.

"Please pray for us so the 40 missing people could be found."

Authorities are continuing to search for dozens who remain buried under debris, including a missing seven-year-old girl.