Federer, playing on two days of rest on Centre Court at the All England Club in London, equaled Jimmy Connors' Open-era record. The No. 3 seed from Switzerland also added to his own mark by making it at least to the quarters at a Grand Slam tournament for the 48th time.
The 34-year-old Federer has not dropped a set through four matches. Johnson, 26, was making his debut in the fourth round of a major.
"I would never have thought I would win the first four rounds in straight sets," Federer told the BBC after the match. "The matches may be tough, but rests are great for professional athletes -- that's huge.
"You can always lose a tournament in the first week, but never win it."
Federer will next face No. 9 Marin Cilic of Croatia, the 2014 U.S. Open champion who advanced when fifth-seeded Kei Nishikori of Japan retired from their fourth-round match. Cilic was leading 6-1, 5-1 when Nishikori, who previously had a rib injury, decided to stop the match.
"I now need to play my best tennis. I have Marin Cilic in the next round -- he brushed me off the court in the U.S. Open a few years ago and I hope to get him back," Federer said.
The 28th-seeded Querrey beat Nicolas Mahut of France 6-4, 7-6 (5), 6-4. Querrey is the first American man to reach the Wimbledon quarterfinals since Mardy Fish in 2011.
No. 21 Anastasia Pavlyuchenkova of Russia reached her first quarterfinal at Wimbledon by eliminating No. 27 Coco Vandeweghe 6-3, 6-3, breaking the American five times.
Australian Open champion Angelique Kerber of Germany, the No. 4 seed, advanced to the quarterfinals by beating Misaki Doi of Japan 6-3, 6-1.