Switzerland's Federer swept the first set in 21 minutes and began the second set with a break of South African Anderson.
“I'm pleased with a rock-solid performance,” said the six-time champion. “I know it's only the quarters but I'm playing great tennis. I hope I can keep it up tomorrow.”
While the second seed was able to make it all look easy, it was a slog for an exhausted Andy Murray as the third-seeded Montreal title-winner needed a shade under three hours to put down Grigor Dimitrov 4-6, 7-6 (7/4), 7-5.
Dimitrov led a set and two breaks before Murray hauled the second set back.
The Bulgarian then owned the third 5-2 but could not close it out despite getting to match point.
Murray gathered the last of his reserves to take the win, his 26th at the tournament which he won in 2008 and 2011.
Djokovic also survived a scare in the pursuit of a first career Cincinnati title, with the top seed holding off David Goffin 6-4, 2-6, 6-3.
Djokovic, aiming to become the first man to win all eight Masters 1000 events, nearly found himself on the sidelines as his 13th-seeded Belgian opponent won the second set and went two breaks up in the decider.
But the experienced Serb pulled back from the brink, levelling at 3-3 and ran out the winner after a tense one and three-quarter hours.
Djokovic stayed alive despite seven double-faults and five breaks of his serve.
Djokovic will face Swiss ace Stan Wawrinka in the next round after the Swiss fifth seed prevailed over Ivo Karlovic to win 6-7 (2/7), 7-6 (7/5), 7-6 (7/5).
“I'm really happy to get the win, you know what to expect from him,” said Wawrinka, who saw 35 aces from Karlovic fly past him. “You need to stay calm and aggressive.
“I'm happy with the way I stayed positive with body language, and always made him play one more ball. You must accept that he will have a lot of aces. I'm happy to get through.”