The 31-year-old Welsh international was deemed surplus to requirements for the Championship leaders after recently returning from a loan spell with Maccabi Tel Aviv.
Earnshaw tweeted: "I have now signed and officially a @Torontofc Player.
"Season starts this Saturday.Now on the plane flying to Vancouver for the opening game.
"I want to thank my home town club Cardiff City,I had the best fun playing in front of those Fans from the age of 16 until now."
Earnshaw leaves Cardiff as the club's second-leading goalscorer of all time with 109 goals in 217 appearances.