St. Louis trailed 5-4 entering the eighth but erupted for four runs to grab control of the game.
With the bases loaded, pinch-hitter Matt Adams grounded a pitch from Brandon Kintzler (3-1) into right field, scoring Kolten Wong with the tying run.
Carpenter then delivered the key blow, chasing home David Descalso with a ground single to left, and David Freese capped the outburst with a two-run double off Bruce Badenhop.
Yadier Molina went 4-for-5 with an RBI, Jon Jay stroked a two-run homer and Carlos Beltran provided three hits, including a bases-empty homer, as second-place St. Louis kept the pressure on National League Central-leading Pittsburgh.
The Cardinals trailed the Pirates by one game coming into the contest.
Michael Wacha (2-0) earned the decision despite blowing a save in the sixth and Edward Mujica picked up his 32nd save for St. Louis.
Exploding whale video goes viral on Internet
Benedict Cumberbatch's dramatic reading of R. Kelly lyrics is just what you need