Quentin Tarantino’s classic “Pulp Fiction,” which just celebrated its 20th anniversary, contains one of the most squirm-inducing scenes in movies: when John Travolta, as Vincent Vega, revives Uma Thurman’s Mia Wallace from a heroin overdose by plunging a hypodermic needle into her chest.

As Mia comes to, gasping for breath, a heavily pierced Rosanna Arquette — playing Jody, the wife of Travolta’s heroin dealer — looks on with sadistic glee, giving the scene its button with the line, “That was f–king trippy.”

But the scene could have ended quite differently — with a jaunty dance party, perhaps? — if Ellen DeGeneres had gotten Arquette’s role, which she read for. Or if Tarantino had cast his first choice for Mia: Danish Amazon Brigitte Nielsen.

To give the drug content credibility, the director asked a friend to coach Thurman and Travolta on the specifics of shooting up and overdosing. Eric Stoltz, who played drug dealer Lance, had already been through movie heroin school, courtesy of Tarantino.

“I had just done ‘Killing Zoe’ [with Tarantino], and I’d met with and filmed a young man doing heroin and talking me through the process,” Stoltz tells The Post. “I think he was a recovered addict who still chipped. It was creepy fun.”

For the pivotal shot of Travolta plunging the hypodermic needle into Thurman’s chest, Tarantino purchased a fake chest from a special-effects company, but ended up changing his mind.

Instead, he filmed Travolta pulling a needle upward, away from Thurman’s chest, then ran the film backward.

The action was cut so quickly in editing that it gives the illusion of Travolta slamming the needle down.

“It’s one of those great, almost Hitchcock-in-‘Psycho’ things,” says Jason Bailey, author of “Pulp Fiction: The Complete Story of Quentin Tarantino’s Masterpiece.”

“It’s cut so close, you never see the impact, but you see right up to it, and you hear the sound effects and you connect the dots in your head.”

One odd touch added to the scene is the presence of Jody’s friend Trudi (actress Bronagh Gallagher), who does little more than smoke out of a bong in the background.

“Quentin thought it would be funny to have this casual observer who just happened to be there,” says Bailey. “All of this was born out of the experience of, when you go to someone’s house to buy drugs, there are always people who are just there.”

The scene had an explosive effect on viewers. When it screened at the 1994 New York Film Festival, a man in the audience fainted just as Vincent sent the needle into Mia’s chest.

“They stopped the film,” says Stoltz. “We were all in a box seat in the balcony, and I was mortified. Later we heard it may have been a stunt. If it was, it was a damn fine one.”

“When you watch it, the audience is broken into thirds,” Tarantino is quoted as saying in Bailey’s book. “A third is diving under their chair, a third is laughing, and the other third is doing both at the same time.”