The Australia Open champion has lost only one match this year after returning from a five-month lay-off, and claimed the tie breaks 7-5 and 7-4 to progress to the quarter-finals in Florida.
Czech Tomas Berdych awaits the Swiss in the last eight after he beat France's Adrian Mannarino 6-3 7-5.
However, the news was not as good for Federer's compatriot and top seed Stan Wawrinka, who suffered a surprise defeat to German teenager Alexander Zverev.
Wawrinka took the first set 6-4 but Zverev converted four of his five break points as he won the next two 6-2 6-1.
Zverov will play Nick Kyrgios in the quarter-finals after the Australia overcame David Goffin of Belgium 7-6 6-3.
Second seed Kei Nishikori was a 6-3 4-6 6-3 winner against Federico Delbonis, with the Japanese player facing Fabio Fognini next after the Italian thrashed Donald Young 6-0 6-4.
Rafa Nadal beat Nicolas Mahut 6-4 7-6 and faces American Jack Sock, who was a 6-2 6-1 winner against compatriot Jared Donaldson.