Hernández signed with the Houston Astros as an international free agent in February 2011.  He made his professional debut that season for the Dominican Summer League Astros. Hernández played 2012 with the Rookie-level Gulf Coast Astros and the Class-A Lexington Legends of the South Atlantic League. He appeared in 59 total games, and recorded a .243 batting average, five home runs, 23 runs batted in (RBI), and 11 stolen bases.  He played the entire 2013 season with the Class-A Quad City River Bandits, and hit .271 with 13 home runs, 55 RBI, and 24 stolen bases.   During the offseason, Hernández appeared in 23 games for the Toros del Este of the Dominican Winter League. 
Hernández started 2014 with the Lancaster JetHawks of the Advanced-A California League, and was promoted to the Corpus Christi Hooks of the Double-A Texas League during the season.  In 119 games, Hernández hit .292 with 21 home runs, 85 RBI, and 33 stolen bases.  He played the entire 2015 season with Double-A Corpus Christi, batting .219 with 17 home runs, 48 RBI, and 33 steals in 119 games.  Hernández began the 2016 season with Corpus Christi, and was promoted to the Fresno Grizzlies of the Triple-A Pacific Coast League in late June.  On August 12, 2016, the Astros promoted Hernández to the major leagues.  He remained with the Astros through the end of the 2016 season, and hit .230 with four home runs and 11 RBI in 41 games. In the minors that year, Hernández batted .307 in 107 games, with 10 home runs, 53 RBI, and 34 stolen bases. 
On March 21, 2017, Hernández was optioned to Triple-A Fresno.  On April 25, 2017, the Astros promoted Hernández to the major leagues to replace an injured Jake Marisnick.  However, he was placed on the 10-day disabled list the next day. 
Toronto Blue Jays
On July 31, 2017, the Astros traded Hernández and Nori Aoki to the Toronto Blue Jays for Francisco Liriano.  Hernández was assigned to the Triple-A Buffalo Bisons.  On August 31, Blue Jays' manager John Gibbons announced that Hernández would be called up on September 1.