Office workers rushed outside as highrises began swaying, while riders were thrown off their motorbikes by the force of the 6.0 magnitude rumble.
It was not immediately clear if there were any casualties.
"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.
The epicentre was off the coast, about 130 kilometres southwest of Jakarta, a sprawling 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.
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.
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)
Follow NDTV for latest election news and live coverage of assembly elections 2019 in Maharashtra and Haryana.
Subscribe to our YouTube channel, like us on Facebook or follow us on Twitter and Instagram for latest news and live news updates.