The earthquake caused no tsunami and there were no reports of damage or injuries, according to the Meteorological Agency and police.
The earthquake was centred near Joetsu City in Niigata prefecture, occurring at 9:26am (0026 GMT) at a depth of 24 kilometres, the US Geological Survey said. The quake shook a wide area on the west coast of the main island of Honshu.
Around 20 percent of the world’s most powerful earthquakes strike Japan, which has developed one of the most sophisticated tsunami warning systems.
The Meteorological Agency issued a warning for a strong quake seconds after it detected the first underground tremors.
The alert was flashed across television screens as presenters on Sunday morning shows called for caution.
Niigata police said there was no major damage.
“Nuclear power plants are up and running and shinkansen (bullet) trains are operating normally,” a police spokesman said, adding it was unclear whether the agency’s warning had been given in time for residents living near the epicentre to react.
The Joetsu area has been rocked by a series of quakes since Saturday.