Sara Bareilles in New York. (Jesse Dittmar/For The Washington Post)

When Sara Bareilles starred in her musical “Waitress” for the second time this spring, and then was a stunningly effective Mary Magdalene in NBC’s live “Jesus Christ Superstar,” and days later got tapped to co-host June’s Tony Awards with Josh Groban, the truth was finally clear. The singer-songwriter of the uplifting cultural anthems “Love Song” and “Brave” has become a bona fide theater person.

“I think I’ve always been a theater person,” Bareilles says, affably, in a production office 11 floors above Broadway, with a view of Times Square. In Eureka, Calif., Bareilles’s mom, Bonnie Halvorsen, closed in a local production of “Nunsense” the night Bareilles was on TV in “Superstar.” Sara acted on the same stage as a kid, and she loved the cast parties.

“We always had theater people around the house,” says Halvorsen, 67, “and I think the kids liked the feel of it.”

“It’s the most welcoming safe space on the planet,” Bareilles says of theater. “Taking a left turn into a pop artist career is not necessarily what I envisioned for myself.”

It’s been five years since Bareilles’s last studio album, “The Blessed Unrest,” because Broadway has so consumed her that Bareilles now categorizes her life into before and after “Waitress”; even her boyfriend Joe Tippett (NBC’s “Rise”) comes from the show’s original cast. Bareilles had already unsuccessfully auditioned for the 2012 Shakespeare in the Park production of “Into the Woods” when director Diane Paulus approached her about writing the songs for an adaptation of the quirky 2007 movie “Waitress.”

The musical opened two years ago and is still running strong, with Katharine McPhee now starring as the unhappily pregnant waitress Jenna (who has an awful husband and a gift for making pies). “They’re having a hard time getting rid of me,” Bareilles says. “Now it’s like, ‘Let go of the baton, Sara.’ ”

Bareilles might even have played the part from the beginning, only Paulus wanted the rookie composer to focus on making the show. Still, Paulus says, there were rehearsal nights when almost everyone else had left and she’d coax Bareilles onstage. “Be Jenna for me, Sara,” she’d day, just to hear Bareilles sing the songs. (Bareilles recorded most of the numbers on the 2015 CD “What’s Inside.”)

Playing Jenna and just plain being Bareilles — whose star caliber has led to singing her 2007 heartbreaker “Gravity” with Elton John and performing at the Oscars and at the White House — begot the “Superstar” casting with John Legend and Alice Cooper. Bareilles not only sang “I Don’t Know How to Love Him” with silvery soul but also suggested to a national audience that she can act.

Sara Bareilles in “Waitress” on Broadway, where she played Jenna for brief stretches this year and last. (Jeremy Daniel)

“Superstar” begot the Tonys gig, which in recent years has gone to cutups such as James Corden, Kevin Spacey and Neil Patrick Harris. A more probable model for Bareilles and Groban is the 2015 co-hosting duo of Alan Cumming and Kristin Chenoweth.

“I wasn’t not nervous about saying yes, but I don’t know,” she says. “Maybe this is going to suck. I don’t think either of us has the delusion about, ‘Let’s make this about us.’ Let us be good conduits for that celebration. And, hopefully, we can be conduits to that new audience who maybe doesn’t know so much about theater, but know us.”

That’s the big evolution, 20 years after Paul Simon controversially flopped with his gangster study “The Capeman” and left complaining that Broadway was an impenetrable insider-y clique. Since then, the ABBA catalogue hit “Mamma Mia!” (in 2002) and the Four Seasons’ story “Jersey Boys” (2006) proved that audiences would flock to pop hits repurposed on stage; that dubious jukebox trend endures this season with Jimmy Buffett’s “Escape to Margaritaville” and the Donna Summer bio-drama “Summer.”

Broadway meets pop culture

But increasingly this decade, singer-songwriters like Bareilles are writing directly for the stage: Sting (“The Last Ship”), Edie Brickell (“Bright Star”), Sheryl Crow (“Diner” at D.C.’s Signature Theatre), Bono and the Edge (“Spider-Man: Turn Off the Dark”), Trey Anastasio (“Hands on a Hardbody,” with Amanda Green), Dave Stewart and Glen Ballard (“Ghost”), Bon Jovi’s David Bryan (“Memphis,” with Joe DePietro), and Cyndi Lauper, whose “Kinky Boots” won a 2013 Tony Award.

“If there was a perception that wasn’t appropriate, that’s gone,” Paulus says of the pop invasion. She’s speaking from Boston, where her production of Alanis Morissette’s 1995 “Jagged Little Pill” is debuting at the Paulus-led American Repertory Theater; Diablo Cody (“Juno”) has stitched a book around Morissette’s album. “It’s exciting that Broadway songs can have a pulse in pop culture, and to be working with best talent in our country.”

Paulus got the “Waitress” material from producer Barry Weissler — they worked together on the 2013 Broadway revival of “Pippin” — and her first notion for a composer was Bareilles. Paulus asked her to watch the movie and not worry about what might be “right,” but to write from the heart. Weeks later Bareilles emailed an MP3 demo of “She Used to Be Mine,” the soulful ballad that drives the musical’s climax.

“I knew in a heartbeat that we had a show,” Paulus says.

“She just understands narrative, not only textually with lyrics, but with melody,” says “Waitress” choreographer Lorin Latarro. “She understood the lead character, and really understood the kind of emotional depth we needed to have on stage to make an impact.”

“I think Diane responded to the humor in some of my songs, and had an intuition about where the tone of the show was going to live, which was straddling a more serious piece and also something that is very playful,” Bareilles says. “That is a good fit for my kind of writing. I don’t think I ever though I was a wrong fit. But there were times where you just don’t know how to solve the puzzle.”

In her 2015 memoir “Sounds Like Me,” Bareilles writes about getting it hilariously wrong with a song for Jenna’s sexually eager husband; the number featured dancing sperm. Messing up as part of a team was “excruciating,” says Bareilles, whose first radio hit, “Love Song,” was an upbeat, defiant ode to independence as she resisted label-sanctioned writing habits.

“It got easier,” she says of “Waitress,” which frequently showcases her music by gliding the live band on stage. “Such a nice takeaway was knowing that not every idea is a good one, and sometimes the bad ideas are a bridge that bring you to somewhere. . . . I definitely fell head over heels for the project,” she adds. “Who knows whether it works or not? I have had songs I was sure were going to be huge hits that didn’t go anywhere, and songs I thought were going to be throwaways that took on a life that I never would have predicted.”

Going back to the studio

Bareilles studied communications at UCLA but found her calling studying abroad in Italy, when she begged her father to ship her a keyboard so she could play. She finished her degree and expanded from performing on the campus scene to the L.A. scene, building a band and writing songs — confessional, jazzy, lyrically frisky. Who was in her ear?

“Fiona Apple,” she says immediately, while tipping her cap to Joni Mitchell, Carole King, Paul Simon and Billy Joel. (She is a self-taught pianist; “I’m so far from being Billy Joel it’s not even funny,” she says.)

“Love Song” put her on the map in 2007, eventually receiving a Grammy nomination as Song of the Year. She fretted that “Brave,” from “The Blessed Unrest,” was somehow formulaic, but the message of courage that she wrote for a friend nervous about coming out as gay quickly became a cultural touchstone.

“I want to say ‘unzipping your soul,’ ” Bareilles says, fumbling toward self-definition. “I have found that my strength is always about sharing what’s vulnerable about me, rather than that I’m some great showman or wildly talented entertainer.”

You see what she means in a video of her guest appearance during a Taylor Swift concert singing “Brave.” Swift is machine-tooled and arena-ready, glamorously costumed and moving like a model with every step. Bareilles bops along almost like a giddy kid.

Singer-songwriter Sara Bareilles performs during a state dinner at the White House in 2016. (Olivier Douliery)

Would she take a role on Broadway? “Totally,” she says. “I’m lucky that I get to have those conversations now.” Eight shows a week is tough, but compared to touring . . . well, she doesn’t hit the road hard any more, the way she did when she was paying her dues. She voices her fans’ complaints: “Yeah, b-, you don’t tour.”

Instead, she’s been tapped to pen songs such as the inspiring “If I Dare” for the Billie Jean King-Bobby Riggs movie “Battle of the Sexes” and the peppy second-act opening number for Broadway’s cartoony “SpongeBob SquarePants” musical. More intriguing is “Seriously,” which the radio program “This American Life” asked her to write during the 2016 presidential campaign, imagining what Barack Obama was thinking as Donald Trump captured the Republican base. “Hamilton” star Leslie Odom Jr. caressed the lyrics over a light, slick rhythm and a haunting string arrangement by “Hamilton” music director Alex Lacamoire:

Let’s talk of fear

And why I don’t bring it in here

It’s a dangerous word, it spooks the herd

And we all bleed in the stampede

Fear makes a false friend indeed

And I take it seriously

“I love and respect Barack Obama so much that I just wanted to offer something that would honor him but still speak to the heart of the matter,” Bareilles says. “It wasn’t meant to be insulting. It was just meant to be an observation. I’m so proud of that song. So proud.”

It’s a reason she’s ready to write more songs and get back to the studio, which is what she’ll do after the Tonys. She’s feeling more focused now than five years ago, when the write-record-tour cycle burned her out. The new album has no shape yet, but Bareilles figures she’ll trust her habit of looking inside. It worked for a decade before Broadway; immediate personal circumstances generated her standbys “Love Song,” “Brave,” and “Gravity.”

“ ‘Gravity’ — I had no intention of making anybody else feel better with that song,” Bareilles says. “I was only self-soothing. They were all teachers to remind me: if I can just speak truthfully to my experience, it will resonate where it needs to resonate.”

Waitress May 15 to June 3 at the National Theatre, 1321 Pennsylvania Ave. NW. Tickets: $48-$203. ­202-628-6161 or