"Danny will add value to the squad. He's a really experienced player," said Hearts head coach Robbie Neilson.
"He's a winner and brings a lot of ability to the squad."
The 28-year-old was on loan from Coventry City at St Johnstone for four months last season. He won the Scottish Cup with Dundee United and left there to join Peterborough in June 2012.
Swanson joined Coventry two years later on a free transfer and made 18 appearances for the Sky Blues.
"He's impressed in training but I also knew him from Dundee United, when I was a player there," added the Tynecastle head coach.
"I know what he brings to the team. I know he's got great technique and ability and he'll be a good addition to the squad.
"He predominantly plays in a more central area of the pitch now. He gives great through balls and passes in that area, which is where we're a little bit light at the moment."
Hearts have signed former Dundee United midfielder Danny Swanson until the end of the season after a successful trial.