Hyland has been very open about her kidney dysplasia diagnosis and the series of surgeries she had to endure over the years which led to chronic pain and depression.

“I have an amazing job and an amazing support system but after 27 years of being sick and in chronic pain every single day, you don’t know when you’re going to have the next good day,” she explained. “It’s really hard.”

“I was very, very, very close,” Hyland told DeGeneres. “I would write letters in my head to loved ones — of why I did it, my reasoning behind it, how it’s nobody’s fault. And I didn’t want to write it down on paper because I didn’t want anyone to find it. … I didn’t want anyone to know I was that close because if I knew, they would try to persuade me.”

She explained that once she “finally said it out loud to someone” it “helped immensely.”

“I’d been saying, ‘I think I need to go see a therapist again,’ And they were like, ‘Why do you need to go see a therapist, you can just talk to me?’ And when I said it out loud they were like, ‘Oh you need to go see a therapist!’ And that’s when I was like, ‘Okay, I don’t think you’re going to help me. I think I need to really do this on my own and really do even more digging and soul searching,’” she recalled.

“I finally said it out loud to someone,” she shared. “Just saying it out loud helped immensely because I kept it to myself for months and months at a time.”

She also said that she would tell someone in a similar frame of mind to talk “to someone and saying it out loud almost makes it sound almost ridiculous but it puts everything into perspective.”

Hyland continued: “Every person with their anxiety, or depression, or suicidal thoughts, every individual is different. So I wouldn’t rely on everything I say, I’m just sharing my story. But I think talking to someone and saying it out loud really, really makes it sound almost ridiculous and puts everything in perspective.”

According to the National Institute of Diabetes and Digestive and Kidney Diseases, kidney dysplasia is a condition in which the internal structures of one or both of a fetus’ kidneys do not develop normally while in the womb. Urine collects inside the affected kidney and forms fluid-filled sacs called cysts. The cysts replace normal kidney tissue and prevent the kidney from functioning.

Hyland required a kidney transplant in 2012 and her father donated her a kidney. In October 2016, her body started to reject her father’s kidney.

WATCH BELOW: Sarah Hyland reveals second kidney transplant

She then started regularly undergoing dialysis — which is a temporary treatment where a machine filters blood in and out — that required to put a tube on her chest.

In May 2017, her transplanted kidney was removed and her 23-year-old brother offered his kidney. That transplant took place in September 2017.

Hyland also has endometriosis and an abdominal hernia. She told DeGeneres that she’s had six surgeries in the last 17 months. And she said that she has had a total of 16 surgeries over the course of her whole life.

The actress told Degeneres that she also had gout, which is a form of arthritis caused by excess uric acid in the bloodstream that crystallizes and deposits in your joints.

“I’ve been through a lot of pain it’s one of the most painful things I’ve ever had,” Hyland said.