"Firework" was written by Perry, Mikkel S. Eriksen, Tor Erik Hermansen, Sandy Wilhelm, and Ester Dean while produced by Stargate and Sandy Vee at Soapbox Studios in Atlanta, Georgia. It was recorded at Roc the Mic Studios in New York City. It was mixed at The Bunker Studios by Vee. Audio engineering was done by Carlos Oyandel and Damien Lewis. All instruments were done by Stargate and Vee. Lead and background vocals were provided by Perry. Perry said that "Firework" is her favorite song on "Teenage Dream".