The former Rangers keeper has put pen to paper on a deal that will see him take up a player-coach role at Tynecastle when his contract at Crystal Palace expires next month.
He is now in line for a return to Glasgow when the Jambos kick off their Championship campaign against Ally McCoist's side.
Alexander said: "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'll be signing on July 1. I'm excited at the challenge ahead.
"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."