The 27-year old left-back left Hearts at the end of last season and has now penned a one-year deal with the Buddies with the option of a further year.
St Mirren boss Danny Lennon was thrilled to welcome Grainger to the Paisley club after losing some key defenders of late.
"Danny is a top quality left back to replace him. I have known Danny since he was a young lad at Gretna and he has gone on to prove himself to be a stand out player in the SPL.
"He has the ability, experience and character we are looking for to help take the club forward and we are delighted to have him on board."