In the final game of the 2017 season, Díaz tore his hamstring. The Cardinals traded Díaz to the Toronto Blue Jays on December 1, 2017, for minor league outfielder J. B. Woodman. He began the season as Toronto's starting shortstop as Troy Tulowitzki was on the disabled list. On May 8, Díaz was placed on the disabled list with a left ankle sprain. In 110 plate appearances prior to being placed on the disabled list, he was batting .216/.273/.431 with six home runs and 13 RBIs. He was activated on June 1. For the season, Díaz hit .263/.303/.453 with 18 home runs and 55 RBIs in 130 games. On November 17, 2018, the Blue Jays traded Díaz to the Houston Astros in exchange for minor league pitcher Trent Thornton. In 2019, he batted .271/.356/.467 with nine home runs and 40 RBIs in 210 at bats. Díaz and wife Dayara have one son, born August 5, 2016. They reside in West Palm Beach, Florida in the offseason.