David Peralta had three hits, Martin Prado homered and Miguel Montero drove in two runs for Arizona.
Paul Goldschmidt broke an Arizona record with his 33rd double before the All-Star break, extending his streak of reaching base to 28 games.
The Diamondbacks had seven extra base hits and went 5 for 10 with runners in scoring position to help Anderson (6-4) end a four-game losing streak.
David Peralta had another big night, driving in three runs, scoring two more and extending his hitting streak to eight games.
Called up on June 1, Peralta reeled off an eight-game hitting streak, the longest to start a career by a Diamondback. He has picked it up again over the past 12 games, hitting .386, including a two-run double in the second inning and a run-scoring triple in the fourth to put Arizona up 6-0.
Through 32 major league games, Peralta has 14 multi-hit games and is batting .330.
Not bad for a player who started his career as a pitcher in the St. Louis Cardinals’ system.
"It’s been unbelievable," Goldschmidt said. "He came up right off the bat, had that hitting streak to start it. He’s put together really good at-bats every time."
He wasn’t the only one hitting against Koehler.
Making his first start since becoming a father, he struggled after pitching well over his previous three starts.
Arizona jumped on the right-hander in the second inning, starting with Prado’s leadoff homer. The Diamondbacks kept knocking balls around the ballpark, going up 5-0 after two-run doubles by Peralta and Montero.
Peralta chased Koehler with a run-scoring triple and Goldschmidt hit a run-scoring double off Jacob Turner to break Luis Gonzalez’s record for doubles before the All-Star break, set in 2003.
Koehler allowed seven runs and eight hits in three innings.
"There is no excuse for pitching that way," Koehler said. "I feel that I was throwing the ball really well over the last three starts or so. It’s just a bump in the road and you’ve got to move on."
Arizona’s bashing allowed Anderson to get back into the win column.
The rookie right-hander won his first five major league starts, but had allowed seven combined runs in his previous two starts.
Anderson pitched well with the big lead, working around baserunners in every inning but one.
He prevented the Marlins from scoring in the fourth after they had runners on second and third with no outs. Miami had two on with one out in the sixth and Anderson held them to a single run, on Adeiny Hechavarria’s sacrifice fly.
Anderson allowed a run and seven hits and struck out eight in six innings.
"I just had fastball command from the get-go and when you have that, you’re going to be successful," Anderson said. "You’re able to throw your other pitches off that and the run support is always nice."
Casey McGehee extended his career-best hitting streak to 14 games and the majors’ longest road hitting streak to 21 games for Miami.
NOTES: Diamondbacks GM Kevin Towers underwent vocal cord surgery in New York on Monday. … San Francisco 49ers coach Jim Harbaugh brought his glove and watched the game from the owner’s box. … LHP Vidal Nuno will make his Arizona debut against Miami on Tuesday. He was acquired from the New York Yankees for RHP Brandon McCarthy on Sunday. LHP Brad Hand will pitch for the Marlins.