Johnson (10-6) struck out six and walked three to become the fourth Florida rookie, and second this season, to win at least 10 games in a season. Ricky Nolasco, who starts against Arizona on Sunday, is 10-7.
"This was probably the best I've felt all year," Johnson said. "I felt powerful. I felt like I could stand back on the rubber and it was downhill."
The 22-year-old right-hander allowed five runs and eight hits in three innings in a 10-2 loss to the Dodgers last Saturday.
"It's just kind of what our young players have done," manager Joe Girardi said. "When they have a tough game, they bounce back. That's a good sign. That's a sign they're maturing and they're not making too much of one day, one outing, a couple of days, a couple of losses."
Hernandez (9-9), acquired this week in a trade with Washington to shore up the Diamondbacks' shaky rotation, allowed four runs and 10 hits in a season-high eight innings.
"I felt good," he said. "I made a mistake with Cabrera. I tried to throw the fastball up and he jumped at it. That was the ballgame right there. I think that was the only mistake I made."
Hernandez had won three straight starts for the Nationals before coming to Arizona.
"When you don't give him much run support, it makes it a little more difficult," Diamondbacks manager Bob Melvin said. "But boy he was throwing the ball where he wanted to and was economical with his pitches. Really the one hit that hurt him was Cabrera, and that was just good hitting."
Joe Borowski pitched a perfect ninth for his 25th save in 28 opportunities.
Johnson's ERA fell to 2.69, which moves him ahead of Arizona's Brandon Webb (2.74) for best ERA in the National League.
"Ten wins in the big leagues my first year, I'll take that anytime," Johnson said.
"The ball just kind of jumps on you, and he had a good slider he was throwing down and in to the lefties, a good changeup at times," Melvin said. "Really, we hadn't been stifled like that for a while."
All of Florida's runs came with two outs.
"You've got to give them credit, but the bottom line is we didn't come ready to play tonight," Arizona's Eric Byrnes said. "We hadn't seen him before and he's got good stuff, but this is the major leagues and I don't think we really showed up tonight. It seemed like we were going through the motions a little bit, and I'm definitely at fault."
Cabrera doubled in Johnson and Ramirez in the seventh to make it 4-0.
- The other Florida rookies to win 10 games were Dontrelle Willis in 2003 and Brian Meadows in 1998.
- Webb (12-4) makes his first start since July 31 on Saturday night. He sat out a turn in the rotation with a sore right shoulder.
- Orlando Hudson went 0-for-4 to snap a 10-game hitting streak.
- Arizona 1B Conor Jackson has not played since being hit in the forearm by a pitch Monday night against San Francisco.
- Johnson's victory was the 36th by a Marlins rookie, most in the majors this season.
- The game lasted 2 hours, 12 minutes.