The song's music video is part of Beyoncé's 2016 film Lemonade, aired on HBO alongside the album's release.
It was written together with Malik Yusef, who came up with an idea for a track called "We Built Sandcastles That Washed Away" which he sang on a piano with "gospel-influenced lyrics".
Vincent Berry II immediately related to the lyrics and promised it would be his "last time writing a song about this girl" while also "putting it all in this".
However, Taylor did not record the song and Berry was invited to a studio with songwriter Midian Mathers, who cried upon hearing "Sandcastles".
"[2] Eventually, he received a call from the singer's team notifying him that the song he wrote was included on the album, along with a production credit he would share with Beyoncé.
[2] As stated by Gerrick D. Kennedy from Los Angeles Times, upon the release of Lemonade many thought it was inspired by an infidelity her husband Jay-Z committed.
[3] The song's music video is part of a one-hour film with the same title as its parent album, originally aired on HBO.