Awaiting him in the last eight on Tuesday is the 100th-ranked Sandgren, who upset 12th-seeded Italian Fabio Fognini over four intense sets.
“It was a tough start, Marton played very clean,” said Federer, who is into his 15th Melbourne quarter-final, surpassing John Newcombe’s 14.
It will be also be his 57th appearance in the last eight at Grand Slams. No one else is close, with Novak Djokovic next in line on 46.
“It just took me some time, I tried to mix it up a bit and just had to figure it out. From the beginning of the second set it got a little bit easier,” he added.
Sandgren, a devout Christian, achieved his best Grand Slam result at Melbourne Park by reaching the last eight in 2018, but it was overshadowed by a row over his political views and links to right-wing activists.
He has put the controversy behind him and shown battling qualities to make the last eight again, and said he was relishing the chance to play an all-time great.
“It will be very special, very special. To play him on a big stage like quarters of a Slam would be a ton of fun really,” he said.
The pair have never met before, as Federer noted: “I’ve played a lot of tennis in my life but never against Tennys.”
The ageless Federer was pushed to a gruelling five sets by John Millman in round three, but showed no signs of tiredness against Fucsovics despite being 38.
Both players took time to feel each other out and it went with serve to 3-3 before the Hungarian grabbed the first break on the back of some high quality service returns.
The unheralded 27-year-old, ranked 67, looked composed, with his power and aggressive forehand unsettling Federer and he held his nerve to grab the set — the first he had ever taken off the Swiss.
Undaunted, Federer kept has cool, started to find Fucsovic’s weaknesses and dictate the points, earning a break to go 2-0 ahead in the second set.
He didn’t let up as the Hungarian struggled to stay in touch, broken again as the tide turned and normal business resumed for the Swiss great.
Fucsovics, who was attempting to become the first player from his country to make the Melbourne quarters, was shellshocked as Federer turned on the style.
He raced to a double break lead in the third with some brilliant passing shots and there was no way back for a player who came into the match in decent form, winning his three previous matches without dropping a set.
Federer, who could face Djokovic in the semi-finals if he gets past Sandgren, wrapped it up in 2hrs 11mins, almost two hours less than his third-round epic against Millman.