The epicentre of Friday's earthquake was located near the coast of Fukui Prefecture at a depth of 10 kilometres (about six miles), according to the Meteorological Agency.
No tsunami alert has been declared.
According to the Kyodo news agency, two people have been injured as a result of the earthquake: an 80-year-old woman and a 2-year-old girl.
Japan is located in a seismically active zone known as the Ring of Fire and regularly suffers from powerful earthquakes. A 9.0-magnitude earthquake and subsequent tsunami in 2011 killed over 15,000 people and caused the Fukushima nuclear plant disaster.