Office workers said the swaying was felt for about 10 seconds in high-rise buildings around the city of 9 million people. Even two-story homes shook strongly.
No damage or casualties have been reported.
The U.S. Geological Survey said the 5.9-magnitude quake hit in the Indian Ocean 100 kilometers (62 miles) southwest of Sukabumi, a town in West Java province. It was about 171 kilometers (106 miles) from Jakarta and 67 kilometers (41 miles) beneath the ocean floor.
Indonesia's Meteorology and Geophysics Agency had the preliminary magnitude at 6.1. Slight discrepancies are common in the initial measurements.
Indonesia has frequent earthquakes due to its location on the Pacific "Ring of Fire," an arc of volcanos and fault lines encircling the Pacific Basin, but it is uncommon for tremors to be felt in Jakarta.