The safest place for a bike is a separate bike lane on the road. If no separate infrastructure exists, the next safest place is on the road.
Edit: People are downvoting this; I guess because they don’t believe it? The law is here[0]. Also 73% of Japanese ride on the sidewalk more than the road[1]. So even without the wide open exceptions to the law, it’s still de facto allowed.
[0] https://elaws.e-gov.go.jp/document?lawid=335AC0000000105#5
第六十三条の四 … 三 前二号に掲げるもののほか、車道又は交通の状況に照らして当該普通自転車の通行の安全を確保するため当該普通自転車が歩道を通行することがやむを得ないと認められるとき。
[1] https://www8.cao.go.jp/koutu/chou-ken/h22/pdf/ref/2-1.pdf
The law is subjective and when you’re rolling around in spandex on a multi thousand dollar road bike and a paramilitary USA “peace officer” stops you, the law doesn’t really matter. You just “yes sir” and hope to be allowed to move on