Mercer scored his fifth goal of the season 28 seconds later on a wrist shot from the bottom of the right face-off circle after taking a one-touch pass from Andreas Johnsson to make it 2-1.
After Swayman made a left-pad save against Tomas Tatar at 6:46 of the second, Marchand made it 3-1 six seconds later on a rebound from the slot.
"It's the best feeling ever when you can do your part and you see guys doing theirs," Swayman said. "It's a great feeling and obviously brings momentum in our side, so I was really happy with that. Good for [Marchand]; he had a great game."
Marchand has scored 11 points (four goals, seven assists) in a six-game point streak.
"A majority of the goals scored in the NHL is around the net, and we have to do a little bit better job of getting there by funneling pucks to the net when you don't have anything," Marchand said. "When we start to do that, we create more opportunities. We got a couple of goals off rebounds; it's something that we need to continue to build into our game."
Bratt pulled the Devils within 3-2 on a one-timer from the right face-off circle at 19:24.
Bergeron scored from the goal line to give the Bruins a 4-2 lead at 10:49 of the third period. Jake DeBrusk scored an empty-net goal at 19:06 for the 5-2 final.
NOTES: Boston is 7-0-3 in its past 10 games at New Jersey, its longest active road point streak versus one opponent. Its last regular loss here was Jan. 2, 2017 (3-0). … Marchand has 50 multigoal games, tying Bergeron for fifth in Bruins history. Phil Esposito is first with 104. ... There was no update on Devils defenseman Ryan Graves, who sustained an undisclosed injury 10:49 into the third period and did not return. "We're hopeful he'll be able to play (Sunday at the New York Rangers)," Ruff said. ... Mercer had his third multipoint game, tying Detroit Red Wings forward Lucas Raymond for the most by a rookie this season. ... McAvoy had six blocked shots and was plus-4. ... Devils forward Tyce Thompson was a late scratch because of an undisclosed injury sustained in a 4-0 win against the New York Islanders on Thursday.