Justin Timberlake admitted writing a song for the 'Trolls' movie was one of the hardest things he has ever done.

While the star has gone on to receive an Oscar nomination for 'Can't Stop The Feeling', he was originally worried that he and co-writers Max Martin and Karl Johan Schuster would not be able to pen a track that would work for the animated characters to sing.

He told The Wrap: ''This has to work for the moment, these characters, and be filmic. It took a second to crack the code. I remember thinking, 'We're not gonna be able to do this.'

''This wasn't just like writing a song for a movie - it was writing a song for characters that are going to sing it in the movie.

''That part had to work, and that's the part that made it a task that none of us had ever done. And we had to push ourselves to do something that works in that way.''

However, once they got started, the trio discovered knew that they could pull it off.

He explained: ''Once we got the hook going, that's usually how it goes. Once you get the hook you can base everything off that.''

Max also admitted he was apprehensive at first but he soon discovered they were on to a winner.

He told Variety: ''[Knowing when the song is ready for release] is one of the hardest calls. [But then I thought] 'what do you mean? It's a feel-good song with Justin Timberlake? What can go wrong?'''