A Reuters witness said the quake shook buildings in the capital, Taipei. The quake had a depth of 22 km (13 miles). No other details were immediately available.
Taiwan, a self-ruled island that China considers its own, lies near the junction of two tectonic plates and is prone to earthquakes.
More than 100 people were killed in a quake in southern Taiwan in 2016, and some Taiwanese remain scarred by a 7.6 magnitude quake that killed more than 2,000 people in 1999.