The 30-year-old Axford is expected to join the Cardinals on Friday night when they begin a seven-game road trip in Pittsburgh.
"John is a reliever that offers experience as both a setup man and closer," said Cardinals general manager John Mozeliak. "He's also a pitcher who brings familiarity with the N.L. Central, pennant race baseball and the postseason."
Axford is 6-7 this season with a 4.45 ERA, no saves and 19 holds in 62 games. He led the NL with 46 saves in 2011 while helping the Brewers to the NL Central title.
Axford, who began his career in 2009 with the Brewers, finished 21-19 with a 3.35 ERA in 268 games. He's 9-for-9 in career save opportunities at Busch Stadium, where he compiled a 1.69 ERA in 16 games.