Switzerland’s Federer, who was knocked out of last year’s Wimbledon quarter-finals by the 20th seed, beat the 32-year-old 6-0 6-4 in just under an hour and a half.
The 37-year-old will now face 19-year-old Denis Shapovalov in the semis.
“It’s going to be a dream come true to play him,” the Canadian teenager said.
Federer claimed the first set in 26 minutes and dominated a nervous Anderson throughout the match.
The South African went 2-0 down in the second, but made a comeback to level the score at 4-4, before a marathon 14-minute game ended with Federer winning his fifth break of the match.
Canadian Shapovalov, who has been tipped to be a future Grand Slam star, beat American Frances Tiaefoe 6-7 (7-5) 6-4 6-2 to reach the semis.
“It’s definitely a match-up I have been looking forward to my whole life,” Shapovalov said about playing Federer.
“The stakes are so high – semi-final of a Masters 1000 against your idol, it’s just a dream come true.”
“He’s one of the big shot-makers in the game. I love his forehand,” Federer, who last won the Miami Open in 2017, said of his final four opponent.
Shapovalov’s compatriot Felix Auger-Aliassime, 18, will face defending champion John Isner in the first semi-final on Friday.
“It’s an exciting draw for John and for myself here, playing these young guys,” Federer added.
“They are not just young, but they are very good, as well.”