The song was conceived during the initial recording of Glory, with the track being written in 2015 by the producers Matthew Koma and Dan Book, with an additional writing provided by Alexei Misoul.
[11] Following the #JusticeForGlory campaign that was launched by Spears's fans on social media during the COVID-19 pandemic, the singer unveiled a new cover art for Glory on May 8, 2020, nearly four years after its release.
[6][19] "Swimming in the Stars" was released to digital download and streaming media on December 2, 2020 as the fourth single from Glory, coinciding with Spears's 39th birthday.
[9][21] On the single cover, Spears crouches on one knee in the sand next to broken chains, wearing gold crop top and high-low sarong skirt, which were made of the same material as her bracelets and shoes.
[22] On the day of release, a visualiser to the song was published on Spears's YouTube channel, featuring the single cover with animated soft waves and glistering stars behind the singer.
[9] Jon Blistein of Rolling Stone wrote that the song "boasts a big drum pop groove, which anchors a wash of atmospheric synths and Spears' unmistakable vocals as she croons".
[6] In The Musical Hype, "Swimming in the Stars" was named a "well-produced record with a relatable theme", where Matthew Koma's production was described as "lush, sleek, and smooth".