San Francisco won its second straight to stay three games behind surprising San Diego in the National League West.
The Giants took advantage of back-to-back throwing errors by pitcher Edwin Jackson in the seventh to create a three-run inning and take a 6-4 lead.
After Nate Schierholtz singled to open the San Francisco seventh, Jackson threw the ball away on successive ground balls from Eli Whiteside and Eugenio Velez. The second of those errors allowed Schierholtz to score the tying run and Torres then put the Giants in front with a triple that brought in Whiteside and Velez.
Aubrey Huff hit two solo homers for the Giants and he drove in a third run in the ninth with a single.
Johnson hit a home run in the second, doubled in the fifth, tripled in the sixth and had a single in the eighth. It was the fourth cycle in the history of the franchise.
Chris Ray (3-0), the third of five San Francisco pitchers, got the victory by retiring the final batter in the sixth. Brian Wilson picked up a four-out save, his 28th of the season.
Jackson (6-9) gave up four runs on eight hits in six innings to take the loss.
Aaron Carter is still in love with Hilary Duff
NBC reportedly holds celebs hostage to Jimmy Fallon's show