Indonesians stand outside office buildings after a strong quake hit Jakarta.

A strong earthquake rattled Indonesia Tuesday, sparking panic, damaging scores of homes and leaving at least half a dozen students seriously injured.

Office workers in the capital Jakarta rushed outside as highrises began swaying, while some riders were thrown off their motorbikes by the force of the 6.0 magnitude rumble.

There were no reports of fatalities, but the government said six students were seriously hurt after the roof collapsed at their high school at Cianjur on Java island near the epicentre of the quake. Two other students sustained minor injuries.

"I was sitting when the building suddenly started shaking," said Jakarta department store worker Suji, 35, who like many Indonesians goes by one name.

"I ran outside the building. It was quite strong and I was afraid."

The United States Geological Survey said the 6.0 magnitude quake struck at a depth of 43 kilometres (27 miles).

There was no warning of any tsunami.

"So far we have counted at least 115 homes" that have been damaged, Abu Salim, a spokesman for volunteer disaster relief group Tagana, told AFP.

"The damage ranges from minor...to serious" cases, including partially collapsed walls.

The epicentre was off the coast, about 130 kilometres southwest of Jakarta, a huge city of more than 10 million people.

"The epicentre is in an area prone to quakes. More aftershocks are very likely," Indonesia's Meteorology, Climatology and Geophysics agency chief Dwikorita Karnawati told Metro TV.

"I'm calling on people to be prepared, especially if you are in buildings with a weak structure," he added.

The tremor came as US Defense Secretary James Mattis was in Jakarta for an official visit.

Indonesia sits on the Pacific "Ring of Fire" where tectonic plates meet, causing frequent seismic and volcanic activity.

At least three people were killed following a 6.5-magnitude earthquake just outside the coastal town of Cipatujah on Java island in mid-December.

The tremor was felt across the densely populated island, causing damage to hundreds of houses and other buildings.

An earthquake struck Indonesia's western province of Aceh in December 2016, killing more than 100 people, injuring many more and leaving tens of thousands homeless.

Aceh was one of the areas worst hit by the devastating 2004 tsunami triggered by a magnitude 9.3 undersea earthquake off the coast of Sumatra.

The wall of waves killed 220,000 people in countries around the Indian Ocean, including 168,000 in Indonesia.

Source: AFP