Talk about range — Sean Hayes, known for playing that beloved, frenetic Jack on “Will & Grace,” couldn’t get much farther from that with his current role: That of God. As in the Lord thy God, creator of space and time, the Big Kahuna Himself.

That’s the task at hand in “An Act of God,” a hearty comedy by David Javerbaum, playing at the Booth Theatre through Sept. 4. Javerbaum, former head writer at “The Daily Show with Jon Stewart,” knows how to pen a joke and Hayes knows how to deliver, sitting onstage in toga and sneakers and chatting with the audience about everything from the commandments (He’s got some new ones for us) to cellphones going off (“You’re lucky I’m God and not Patti LuPone”). And if you’re having déjà vu right now, you’re not crazy — the show was on Broadway a year ago, starring Jim Parsons.

Hayes, 45, debuted on Broadway in 2011 in “Promises, Promises.” He’s also a producer (“Hot in Cleveland,” “Grimm”) and YouTube regular (he and husband, Scott Icenogle, perform a series of popular lip-sync videos).

How much of the show was rewritten for you?

We only tweaked a few references here and there out of the 45 pages. It wasn’t hard. David Javerbaum’s a genius. Even if I had nothing to do with this, I’d say it’s one of the funniest things I ever read.

advertisement | advertise on newsday

What struck me is how this works — and is funny — whether you’re a believer or not.

Yeah. It doesn’t discredit God. He admits God exists. It’s the extreme interpretations of any god that are frightening. Religion is in the news every single day. Whether it’s positive news or horrible news. So to have a piece that explores what everybody is talking about every day is really . . . invigorating. Exciting. And thrilling theater.

So why is the show coming back to Broadway so soon?

I have no idea. I got offered to do it in L.A. — it went well, so we went on to San Francisco — that went well, so the producers said, “Do you want to do it on Broadway?” I said, “Not really.”

@Newsday

Really?

No. I said, “Yeeeeah, of course, I’d love it!” It’s back because the material’s been so well-received.

One blast-from-the-past question: How hard was it for you to transition from “Just Jack” of “Will & Grace” fame to “just anyone else?” Was it tough to move on?

advertisement | advertise on newsday

No. I think every actor brings a lot of themselves to every part they play. Every single actor. And so . . . a lot of me was in Jack, but a lot of me isn’t. It just took people a little time to realize that. You’re introduced to a character first, before you’re introduced to the actor. Therein lies the blessing and the curse. But to me at this age, it’s all blessing.

On a different note — you and your hubby have made some funny lip-sync videos on YouTube. How do you pick the songs?

That’s all Scotty, my husband. He’s a genius. He’s a music producer and writes music. So he just chooses the song he thinks is going to be a hit. And he’s 99 percent right. Even the record labels call and say, “How did you know this was the song we were going to release?” Scotty just has an ear for it.

advertisement | advertise on newsday

I’ve been talking to a lot of comedians this year, and I’ve asked — were you always funny, and did you always know it?

I think I was always funny — it was my way of getting noticed in a big family. Did I know it? I knew I was being silly. I didn’t know if it would translate into laughs from audiences. My favorite show growing up was probably “Saturday Night Live.” And I loved John Ritter on “Three’s Company.” Anybody who was physical — I thought that was fun. And so I’ve been trying to do physical comedy ever since.

Where does funny come from? Is there a funny gene or is it how you see the world or . . . ?

It’s the oldest cliché in the book. It all comes from pain. Talk to any therapist. It’s . . . it’s most likely to cover up something. Somewhere you’d rather not go, so you cover it up with comedy.

Oh. . . . That makes me a little sad for you.

Well, that’s why there are phrases like “sad clown.” Or “comedy comes from pain.” It’s all true. It’s not just words. That’s a different interview, Joe.

Ahh, yes. And there’d be a couch, a picture of Sigmund Freud, and I’d get paid by the hour.

Exactly [he chuckles]. And that talk you couldn’t print.