The Russian, who is at a career-high ranking of 15, saw off American Reilly Opelka 7-6 (7/5), 6-7 (5/7), 7-6 (7/0) and has won four ATP hard-court titles, including three since last August. Federer beat him twice last year but is already a fan.
“He’s clever how he plays the court because he can play it up and down, and he’s unusual when he plays from back,” said the Swiss, who hit 14 aces and won an impressive 74% of points on his first serve.
“It’s a bit of a different approach. Thankfully I played him last year twice in Basel and Shanghai and I’m very impressed about his progress. I must say the last year has been unbelievable for him.”
Krajinovic struggled with injury last year as problems with his ankle, left foot and hand restricted him to just seven tournaments in the first seven months of 2018.
Yet some fierce hitting from the back of the court surprised the predictably pro-Federer crowd and a brilliant run and flick over the net handed him an early break for 3-2. Keeping the pressure on, however, was a different matter as Federer broke straight back before pocketing the opening set.
The second set wasn’t as competitive, Federer easing home and finishing with 35 winners compared to the Serbian’s 18.
Simona Halep downs Venus Williams
Elsewhere, number 24 seed Grigor Dimitrov was beaten by world number 77 Jordan Thompson in straight sets ensuring the Australian will meet 2018 Wimbledon finalist Kevin Anderson who beat Portugal’s Joao Sousa 6-4, 7-6 (8/6).
Simona Halep, meanwhile, got the better of Venus Williams once again as the Romanian made light work of the 38-year-old American to book a place in the quarter-finals with a 6-3, 6-3 win.
“I was pretty strong with my serve and knew where to bother her,” said the reigning French Open champion who will meet China’s Wang Qiang in the last eight.
“When I saw I can win easy games with my serve, it gave me great confidence,” she added.
Bianca Andreescu, the 18-year-old Canadian sensation who won the title in Indian Wells, was forced to withdraw in the second set of her fourth-round match with Anett Kontaveit.
Andreescu was 1-6 0-2 down before a shoulder injury ruined her chances of another run to the finals.
The Estonian will meet Taiwan’s Hsieh Su-Wei who continued her excellent form with a 6-3, 6-7 (0/7), 6-2 win over Caroline Wozniacki.
Petra Kvitova, the world number 3, booked her place in the last eight, beating Caroline Garcia 6-3, 6-3 in a match which was held up for one hour and 40 minutes because of rain in South Florida. Kvitova plays Australian Ashleigh Barty for a place in the semi-finals.