Taylor Swift has released a new single titled Carolina, which she “wrote alone in the middle of the night”, for upcoming film Where the Crawdads Sing.

The track, released at midnight on Friday, reportedly plays over the end credits of the film adaptation of the book by Delia Owens.

Swift, 32, shared a video of clips from the film to Instagram, accompanied by the caption: “About a year and half ago I wrote a song about an incredible story, the story of a girl who always lived on the outside, looking in.

“Figuratively and literally. The juxtaposition of her loneliness and independence. Her longing and her stillness. Her curiosity and fear, all tangled up.

“Her persisting gentleness… and the world’s betrayal of it.

“I wrote this one alone in the middle of the night and then @aarondessner and I meticulously worked on a sound that we felt would be authentic to the moment in time when this story takes place.

“I made a wish that one day you would hear it. ‘Carolina’ is out now.”

The 11-time Grammy award-winner previously said she “got absolutely lost” in the book when she read it and had wanted to be part of the musical side of the production.

The film, produced by Reese Witherspoon, follows the story of Kya, a young girl who lives alone in the marshes of North Carolina and becomes enveloped in a local murder mystery.

Kya is played by English actress Daisy Edgar-Jones, who gained recognition for her role in the BBC adaptation of Sally Rooney’s Normal People.

The release of Carolina comes amid Swift’s work to re-record her first six albums after the master recordings were acquired by talent manager Scooter Braun.

By creating new versions of the songs, the star can regain ownership of the music.

She most recently released a re-record of This Love from her 2014 album 1989.

The song’s release hints towards 1989 being the next album Swift plans to re-release in full.

Where the Crawdads Sing is set to be released in the UK on July 22.