Wade Allison tied the game 1-1 at 1:04, knocking the rebound of his shot away from Connor Clifton and past Swayman for his first goal in 19 games.
Pastrnak put the Bruins ahead 2-1 at 2:04 of the second period when his shot along the ice beat Sandstrom.
Boston made it 3-1 at 7:31 on Pastrnak's one-timer from the left face-off circle.
He completed his third hat trick of the season when he finished a 2-on-1 with Bertuzzi to put Boston ahead 4-2 39 seconds into the third period. It was his 300th NHL goal and extended his point streak to eight games (11 goals, two assists).
"It's easy when you're passing it to him," Bertuzzi said. "He was feeling it tonight. It's a big accomplishment for him. He's been a great player for this team this year. It was good to see him get it."
Pastrnak credited teammate Brad Marchand for making him believe 60 goals was possible after he scored 48 in 70 games in 2019-20
"'Marchy' told me many, many years ago, when I was young, he said, 'You have to always aim 10 goals higher than you think you can get,'" Pastrnak said. "So I was aiming at 60. Wasn't really thinking I would get there.
"I know what kind of player I am in this League right now, and I came really close before COVID, so I knew I could do it. That helps with your mindset."
The Flyers stayed in the game when Farabee scored to make it 3-2 at 13:58 of the second. After Pastrnak's third goal, they got within 4-3 at 9:06 of the third on Tippett's goal.
Zacha closed the scoring at 16:56.
"We've had that most of the year," Philadelphia coach John Tortorella said. "We've been chasing games all year long. ... It's something they can lean on as we continue to try to build this."
NOTES: Pastrnak is the second player to score 60 this season, along with Edmonton Oilers forward Connor McDavid (64). It's the first time two players have scored 60 in the same season since Pittsburgh Penguins teammates Mario Lemieux (69) and Jaromir Jagr (62) in 1995-96 ... The Bruins have 131 points, tied with the 1995-96 Red Wings for second in an NHL season; one behind the 1976-77 Canadiens. ... Boston played without forward Patrice Bergeron (undisclosed), defensemen Charlie McAvoy (undisclosed) and Dmitry Orlov (back) and goalie Linus Ullmark (lower body). Forward Taylor Hall was scratched for precautionary reasons after playing Saturday, his first game back after missing 20 because of a lower-body injury. ... Connor Carrick, who was recalled from Providence of the American Hockey League on Sunday, played in his first NHL game since May 6, 2021, with the New Jersey Devils. His assist on Coyle's goal was his first point since April 7, 2021, against the Flyers. ... The Bruins went 4-for-4 on the penalty kill, have killed off 38 straight and have not allowed a power-play goal in nine games.