World No 2 Djokovic defeated unseeded Anderson 6-4, 6-2 in a quarterfinal match at the $9 million ATP Masters 1000 hardcourt tournament.
"When I was two breaks up in the second set I was comfortable sure, but not before that," Djokovic said. "In the second set I found that momentum, but I went through situations where I faced a couple of break points in the first and second set, and I saved them.
"I was fortunate in those moments."
Djokovic, who has won all of his 22 matches this season, will face American Mardy Fish in the semifinals.
Djokovic has now won 24 consecutive matches dating back to last year's Davis Cup final.
"You obviously get confidence with 24 wins in a row," he said. "It keeps getting better. But I don't want to be carried away with that.
"I want to keep on working hard and taking one match at a time. When it stops, it stops."
The Serb is looking for back-to-back titles in Indian Wells and Miami. It would be his fourth title this season to go with victories in Dubai, Indian Wells and the Australian Open.
Anderson became South Africa's first ATP winner in more than five years when he took the title in Johannesburg in February.
Anderson won their only prior meeting by beating Djokovic in three sets in the second round here three years ago.
At the time, Djokovic was ranked third in the world and Anderson was ranked 122nd.
Djokovic will be the heavy favourite against 14th seeded Fish who will pass Andy Roddick as the No 1 ranked American player when the next ATP Tour rankings come out.
Fish has had an up and down year, making two semis in Delray Beach and Memphis but losing in the second round of both the Aussie Open and Indian Wells. He lost twice this year to 20-year-old Milos Raonic of Canada in the second round at Indian Wells and the semis in Memphis.
Fish ousted an ailing David Ferrer 7-5, 6-2 to reach the semifinals.
While Ferrer had plenty of praise for Fish's strong performance on serve, he said he could not really rise to the challenge because of a stomach ailment.
"I think it's the digestion," Ferrer said. "I went to the court, and I when I run to rallies, a lot of pain in my stomach. In the second set, I cannot run anymore."
Djokovic said like Anderson, he can't look past the match with Fish.
"I think he's on a great run," Djokovic said. "He's been playing some really good tennis this week, beating high-ranked players, quality players.
"I watched him play today and he looked really confident on the court. If he serves well, then he can really beat anybody."
The victory ensures Fish will climb to at least 11th when the rankings are next released, while Roddick will fall from eighth to 14th after losing his tournament-opener last week.
"It's very humbling," Fish said.