Steyn's 439 wickets for the Proteas in 93 Test matches have come at an average of 22.95.
Anderson, with 630 Test wickets is third on the all-time list behind spinners Shane Warne (708) and Muttiah Muralitharan (800). However, Anderson's wickets have come in 165 Test matches at an average of 26.51.
The 38-year-old Steyn had played very few Tests in recent years due to injuries.
"Today I officially retire from the game I love the most. Bitter sweet but grateful," said Steyn in a note on his Twitter handle on Tuesday.
The right-arm pace bowler took 26 five-wicket hauls.
He also played 125 ODIs and 47 T20Is taking 196 and 64 wickets in the two formats respectively. At his peak, he formed a deadly combination with Morne Morkel and Vernon Philander.
"It's been 20 years of training, matches, travel, wins, losses, strapped feet, jet lag, joy, and brotherhood. There are too many memories to tell. Too many faces to thank," he added in his note.
"So I left it to experts to sum up, my favourite band, the Counting Crows," he wrote while putting out American band Counting Crows' lyrics in his farewell note.