The 36-year-old will join as player-coach on July 1 when his contract with Crystal Palace expires - he made one appearance for the Eagles last season, in the Capital One Cup.
Alexander told the club's official website: "As a boyhood Hearts fan, I am delighted to get the chance to join a club I have supported for many years.
"With the coaching side of it as well, this is a fantastic opportunity for me.
"I'm excited at the challenge ahead, am raring to go and delighted to be back in Scotland.
"At 36, I need to start looking to the future and want to get involved in coaching. The club has given me a great chance to get a foot on the ladder and it's an opportunity I just couldn't turn down.
"We have a young squad and if I can help bring on these kids, hopefully it will work well for us all."
Alexander could make his debut against former club Rangers, who he left a year ago following a protracted contract wrangle, with Hearts due to open their Scottish Championship campaign at Ibrox.
"With the fixtures now out, it really gives you an incentive to be involved in the first game," he said.
"It's a really exciting start for us and I definitely want to be involved on August 9."
Alexander comes in after last season's first-choice goalkeeper, Jamie MacDonald, was surprisingly released. Back-up Mark Ridgers was also freed and joined St Mirren.
Alexander will join James Keatings, Soufian El Hassnaoui and Morgaro Gomis in signing under new management team Craig Levein and Robbie Neilson.