A dead ex-girlfriend inspired the comedy routine that gave Ellen DeGeneres her big break.

The Finding Dory star was a struggling waitress in her early 20s when her girlfriend was killed in a car crash, and in the desperate weeks and months that followed Ellen came up with one of her most famous skits.

Appearing on pal Dax Shepard's new Armchair Expert podcast, she recalled, "I was living with her when she was killed. I couldn’t afford to live where we were living together and so I moved into this tiny little basement apartment.

"I moved into this basement apartment and I was sleeping on a mattress on a floor and it was infested with fleas. And I used to write all the time, I wrote poetry and songs and stuff, and I thought, 'Why is this beautiful 21-year-old girl just gone and fleas are here?'

"I just thought it would be amazing if we could just pick up the phone and call up God and ask questions and get an answer... It just unfolded, I just wrote the entire thing and when I finished, I read it and I thought, 'Oh my God, that's hilarious. I'm going to do this on Johnny Carson (Tonight Show) and I'm going to be the first woman in the history of the show to be asked to sit down'."

Ellen's prediction became reality when she made her debut on The Tonight Show Starring Johnny Carson in November, 1986. The star's wife, Portia de Rossi, played that Carson episode at DeGeneres' recent 60th birthday party.

DeGeneres previously opened up about the death of her girlfriend during an interview with Oprah Winfrey in 2015, explaining the couple had broken up after a fight and Ellen ignored her ex's attempts to get back together at a gig.

"She was trying to get me to come back home (and) I acted like I couldn’t hear her because the music was too loud," she recalled.

The ex was killed later that night as she drove home alone.

"That, of course, made me feel like I should have gone home with her that night," DeGeneres said. "In an instant, she just was gone. It shifted my entire focus."