The Barcelona star netted his second international treble as Luiz Felipe Scolari's side recorded an impressive win at Soccer City in Johannesburg
Oscar got the ball rolling for the Selecao by scoring after just 10 minutes, before Neymar made it 3-0 with goals either side of half-time. Fernandinho made it four late on before Neymar completed his hat-trick in stoppage time.
Brazil largely dictated the tempo in the early stages and were duly rewarded with the opening goal after 10 minutes.
Hulk collected the ball on the right-hand side and his wonderful well-weighted pass behind the South Africa defence found Oscar, who sprung the offside trap and calmly dinked over Williams.
South Africa responded with Bernard Parker's flash shot from the edge of the area that went wide of the far post before the hosts were dealt a further blow when centre-back Bongani Khumalo was taken off the pitch on a stretcher following a collision with Marcelo.
Shortly before the half-hour mark, Brazil wasted a great chance to make it 2-0. Neymar pounced on a misplaced pass in midfield and surged towards Williams, but the goalkeeper stood up well to deny the Barcelona forward's chipped finish.
Neymar was proving a constant menace, however, and he finally got his name on the scoresheet five minutes before the break.
The 22-year-old drove at the South Africa defence before feinting left and drilling under Williams' legs from the left of the box.
And it took just 22 second-half seconds for Neymar to grab his second of the game, when he latched on to Fred's flicked pass and finished with a superb lob over Williams.
Willian - who had replaced Hulk at half-time - came close to a third soon after, the Chelsea man curling wide from the left-edge of the area.
South Africa replaced Parker with Ayanda Patosi shortly after the hour mark and he almost had an immediate impact with a close-range strike that forced Julio Cesar into a fine reaction save.
Fernandinho added further gloss to the scoreline with a fierce 30-yard effort that nestled in the top corner. And Neymar grabbed his third in the closing stages when he swept home Jo's knock down.
Brazil have now lost just once in 19 games and will play further friendlies with Panama and Serbia before the World Cup.