'Glee' star Chris Colfer was warned not to come out as gay - because it would "ruin" his "career".

The 34-year-old actor portrayed the openly gay character Kurt Hummel on the hit Fox musical comedy-drama from 2009 to 2015, but he was informed he wouldn't get far if he declared his own sexuality.

Appearing on 'This View' amid Pride Month, he recalled: “I grew up in a very conservative town where being openly gay was dangerous.

“I remember when I got on the show, the role was written for me, but I did not know what the role was going to be.

“So, I opened the script and when I read the script for the first time is when I saw that it was an openly gay character.

"When I started filming the show, I had a lot of people tell me, ‘Do not come out, whatever you do, because it will ruin your career.'"

The author claims he was even told he would benefit from not addressing his sexual preference.

He said: “I can’t hide it.

“They said, ‘Don’t worry as long as you never address it, you’ll be rewarded for it in the end.'"

It was after a fan handed him a note during a 'Glee' autograph signing event that he decided it was time.

He added: “I opened it up and there was a little note that said, ‘Thank you’ and there was a little paperclip chain that was in the colours of the rainbow. In that moment I knew, I have to come out.

"At the time, I was thinking if I’m an openly gay actor I may never win a major award and I may never get to play a superhero, but I think being a beacon of positivity and providing comfort for people is way more important.”