The third-seeded Swiss had easily accounted for Russian qualifier Alexander Kudryavtsev in 98 minutes in the first round then had a walkover in the second following Andreas Beck's withdrawal with a lower back injury.
Karlovic's 2.08m height created odd service angles for Federer, but the 16-time grand slam winner used his court craft and foot speed to punch returns down the line or cross court and seize what break opportunities he could.
Federer will meet the winner of the match between Australian teenager Bernard Tomic and 13th-seeded Ukrainian Alexandr Dolgopolov.