20 Time Grand Slam winner says knee injury will prevent him from competing in Japan.
Knee problems have sidelined Federer from another Olympics.
Federer sat out the 2016 Rio games because of problems with his left knee. This time he announced on Twitter that unspecified knee injuries have set him back.
"I'm greatly disappointed, as it has been an honor and highlight of my career each time I have represented Switzerland. I have already begun rehabilitation in the hopes of returning to the tour later this summer.
Before Wimbledon, in which he was eliminated in the quarterfinals, Federer has only played eight matches this season.
Other big names have also announced they will not be attending the games in Tokyo. The city is currently under an emergency order and will not allow fans to attend. The city is allowing restaurants and other businesses to remain open.