It is that time of year when my poor dog cowers under the bed as the rocket's red glare of fireworks is seen and heard across the country. Perhaps I am stealing from my fellow writer and chemist, Dr. Bloom, but I just wanted to share what I had learned about the chemistry underlying all that color filling our skies.
The first fireworks came from the country that “discovered” gunpowder, China, roughly 1400 years ago. As I learned and experimented with in the fifth grade, gunpowder is a combination of charcoal, sulfur, and “saltpeter,” aka potassium nitrate.  When ignited, gunpowder releases energy and gases in an exothermic reaction.
Without an exit strategy, those gases and energy cause an explosion. That explosion creates the pop of firecrackers, probably the oldest form of fireworks.
By channeling that energy through one end of a container, commonly referred to as the nozzle, it will push that container in the opposite direction. Fireworks use both; a cardboard “shell” lifts its payload into the air because it has a nozzle. When at the “right height,” the payload explodes. I saw “right height” because a time-delayed fuse controls the ignition of the burst component; altitude is not a metric but the result of the speed that the shell moves upward and the time delay on the burst ignition.
The Bursting in Air
In addition to gunpowder fueling the explosion, the burst contains “stars,” individual pellets that combine fuel, color producers, and a binding agent. Because of the way bursts are manufactured, they need additional oxygen to “light their fire.” That oxygen comes from oxidizers that can rapidly donate their oxygen molecules. Potassuim chlorate (KClO3) is an example of an oxidizer. Sparklers are a different form of these stars, coating the outside of a wire. The coating contains gunpowder balanced with oxidizers to burn more slowly and metallic dust.
The color in sparklers and stars comes from metal or metal salts heated or ignited in that explosion. Each compound has a characteristic glow. Here is a breakdown.
The designs created by the explosion are based on how the individual stars are packed and arranged.
The Big Bang
Fireworks are always accompanied by the sound of an explosion and a whistling sound. The whistle is a result of the tube construction. Explosions are often enhanced with additional chemicals to literally give us more bang for our buck. And because those sounds are waves of air, a bigger bang means we can often feel our fireworks.
Fireworks can be dangerous. Certainly, those bursting over the sky as part of exhibitions should only be used by pyrotechnic professionals. I wrote about two years ago that fireworks might also have environmental consequences (Spoiler alert: not so much).
 I presume that God protected me from my experiments because of my youth. Making your own gunpowder is dangerous and requires the judgment of a ten-year-old boy – it should be avoided.
Sources: The Boom in Fireworks