In her 20s, Brittany O’Neill was a self-proclaimed mess.

Then living on the Upper West Side, she smoked a pack and a half of Marlboro Lights a day, had six figures of student loan debt and her job running a theater company had some unhealthy side effects.

“In the entertainment industry, you go for drinks before the show, and then you meet donors at a show, and then afterward, you go out with the cast and drink for another three hours,” O’Neill, now 35 and living in Brooklyn, tells The Post. “And then you’re drunk, and you’re like, ‘Well, I need to eat two cheeseburgers, I guess!’ ”

The 5-foot-6 O’Neill ballooned to 227 pounds before she decided to shape up in 2011. Too embarrassed to attempt an outdoor jog, she headed to the gym and slowly pounded out 2 miles on a treadmill. She’d only run here and there before, but this time, something clicked. She was hooked. After eight months, she came up with a goal: She was going to conquer the New York City Marathon.

O’Neill’s best friend and roommate at the time, Paul Downs Colaizzo, 34, was inspired almost immediately to make a movie based on her journey.

The resulting “Brittany Runs a Marathon,” written and directed by Colaizzo, hits theaters Friday after winning the coveted Audience Award at the Sundance Film Festival in early 2019. The comedy stars Jillian Bell — scene-stealer of “22 Jump Street” — as a fictionalized, messier version of Brittany whose path to the start line is by turns hilarious, heartwarming and gut-wrenching.

“I wanted to start with somebody that you underestimated, like the funny sidekick,” Colaizzo tells The Post. “And over the course of the film you slowly peel back the layers and ask the audience to empathize with somebody that they’ve been taught to laugh at in movies their whole lives.”

Colaizzo filled O’Neill in on his movie plan well before her race date.

“I said, ‘I’m writing a movie about you,’ ” says Colaizzo. “She said, ‘What’s it called?’ I said, ‘ “Brittany Runs a Marathon.” ’ She said, ‘How fast does she run in it?’ ”

O’Neill was laser-focused in her quest. She stopped eating processed foods and lost 70 pounds. She sourced a training plan from Pete Pfitzinger and Scott Douglas’ book “Advanced Marathoning” and incorporated dynamic self-coaching from Brad Hudson’s “Run Faster From the 5K to the Marathon: How To Be Your Own Best Coach.” A soundtrack of Beyoncé and Salt-N-Pepa helped keep her going as she experienced years of triumphs and setbacks. By November 2014, she was ready to race. She completed the 26.2 miles in an impressive 3:55:57, crushing her goal of four hours.

O’Neill now works for a refugee-resettlement agency and still runs regularly, although she says she’s not likely to do another marathon because of tendinitis. After years of struggle, she says she’s at a good point with the number on the scale and how she feels about herself.

“I’m always sort of changing my expectations of myself and trying to find that sweet spot between self-improvement and self-acceptance,” she says. “And I’m learning that those two don’t have to be mutually exclusive.”