Federer fired 12 aces — his fastest serve registering 131 mph — and never faced a break point against Johnson, who reached 136 on the radar gun and fought off all four break points against him.
Nadal advanced with a 6-3, 7-5 win against 26th-seeded Fernando Verdasco for his 50th career victory at the desert tournament, where he's won three titles but none since 2013.
"The third set was the best tennis I've played this year probably," Djokovic said. "I'm just hoping I can carry this confidence, especially on the return, to tomorrow's match because I'm going to need that."
On the women's side, No. 2 seed Angelique Kerber lost to 14th-seeded Elena Vesnina 6-3, 6-3 in the fourth round. Kerber is assured of retaking the No. 1 ranking from injured Serena Williams next week.
No. 9 Madison Keys was beaten by 2011 champion Caroline Wozniacki 6-4, 6-4.
Federer is a four-time champion at Indian Wells who won his last title in 2012. He defeated Nadal in the Australian Open final in January for his record 18th Grand Slam title. Their meeting on Wednesday will be the earliest they have played since their first match in 2004 at Miami, where Nadal won.
"Because it's early in the tournament, I think we both don't quite yet know to 100 percent how everything feels," Federer said. "There is a bit of the unknown, which is exciting maybe for the fans to see how we're going to try to figure that part out."
Federer hit 32 winners against Johnson, including a forehand volley that earned him a mini-break in the first set tiebreaker. He won five of the next six points and closed out the set on Johnson's desperate backhand lob that landed wide.
Johnson held at 6-all to force the second tiebreaker and fell behind 4-2. He broke Federer for a 4-all tie before Federer won on his second match point when Johnson netted a backhand.
"In the second set, I think he was serving almost 90 percent at one point," Federer said. "That's why I changed my position on the return. I was trying to mix it up a bit."
Nadal closed out his 1 1/2-hour, third-round match in 95-degree (35 C) heat with a forehand winner.
Nadal won 80 percent of his first-serve points and three of five break points. Verdasco, who won eight straight points for a 3-2 lead in the second set, had seven double faults.
Nadal called it unlucky that he and Federer were to play before the quarterfinals. The Spaniard leads the rivalry 23-12, including a 9-8 edge on hardcourts.
"It doesn't matter if everybody is playing well because from our part of the draw, only one of us is going to be in that semifinals," Nadal said. "So that's tough, but that's not happening every week. Only thing we can do to avoid that is be in higher position of the ranking."
French Open champion Garbine Muguruza of Spain planned to watch the latest chapter in the Federer-Nadal rivalry.
"I think everybody is going to watch that match," she said. "Everybody likes Rafa. Everybody likes Roger. It's history over there."
Venus Williams advanced to the quarterfinals for the first time since 2001 with a 3-6, 6-1, 6-3 victory over Shuai Peng, the last remaining qualifier in the draw. She had 40 winners, 40 unforced errors and won the final four games of the match after trailing 3-2.
"It was so frustrating," Williams said. "But I feel like I got my focus more in that second set and towards the end of the third because I'm just a competitor. If things get closer, then I think my better tennis is going to come."
Williams ended her 15-year boycott of the event last year, when she lost in the second round.
In other women's matches, No. 3 seed Karolina Pliskova advanced when 15th-seeded Timea Bacsinszky retired trailing 5-1 in the first set; Muguruza defeated No. 10 Elina Svitolina 7-6 (5), 1-6, 6-0; No. 19 Anastasia Pavlyuchenkova outlasted No. 5 Dominika Cibulkova 6-4, 3-6, 6-3; and No. 8 Svetlana Kuznetsova beat 21st-seeded Caroline Garcia.
On the men's side, No. 4 seed Kei Nishikori routed 25th-seeded Gilles Muller 6-2, 6-2; American Donald Young defeated 14th-seeded Lucas Pouille 6-4, 1-6, 6-3; No. 15 Nick Kyrgios beat No. 18 Alexander Zverev 6-3, 6-4; and Malek Jaziri got by American wild card Taylor Fritz 6-4, 3-6, 6-3.