Arizona has taken two of three from St. Louis in a four-game series between division leaders.
Reliever Maikel Cieto hit Willie Bloomquist with a pitch later in the inning to load the bases, setting up the two-out, grand slam from Goldschmidt.
Arizona added three more in the eighth, two of the runs coming on a single by Gerardo Parra.
Starter Wade Miley (4-5) picked up the victory by holding St. Louis to three runs on 11 hits in 6 2/3 innings. The loss was charged to Joe Kelly (0-3), who surrendered two runs (one earned) on four hits in 5 2/3 innings.
Justin Bieber crashes Drake Bell's album release party
Rosie O'Donnell unveils nearly 50-pound weight loss