Nearly everyone likes fireworks, with the exception of cats. (Cats hate them with a fiery passion like the cuddly little haters they are.) Something about the bright colors against a black sky appeals to our imagination. For me as a chemistry-type person, I love fireworks shows for an additional reason — because fireworks are a beautiful display of some simple yet violent chemistry in action.

As a general rule, selfish people don’t get along well with other selfish people, and the same is true of elements. As you go towards the upper right-hand corner of the periodic table, elements get more selfish about how they share electrons, as you can see in the chart below. The higher the number, the more selfish the element. Fluorine is the undisputed king. This is by no means the only trend that determines how elements behave; other things like size and available orbitals are very important. But it’s a good general rule that if you see oxygens, chlorines and/or fluorines bonded to each other, the resulting molecule is probably not very happy. It may blow up at room temperature or it may need you to give it a push in the form of heat and a spark, but make no mistake, it wants to react with a molecule made mostly of less selfish elements (aka a fuel).

So chlorine trifluoride, for example:

is a hideously unhappy molecule, and you don’t need to make it to know that. It’s dying to react with somebody, anybody, really. From what I’ve heard (most chemists have never worked with this stuff) chlorine trifluoride reacts explosively and violently with water, brick, concrete, asbestos, wood, sand and safety gloves. Basically anything and everything, in other words. Some Nazi scientists made some of this because they were looking for new ways to blow things up and even they decided it was too nasty to play with.

OK, so that’s kind of an extreme example. How about this one? Oxygen gas.

We don’t think of this as very dangerous, because it’s in the air we breathe, but watch what it does when you give it a spark and some fuel. Those two oxygen atoms aren’t very happy about being stuck together, and they’d really like to react with some carbon-containing compound to make water and carbon dioxide, both of which are much more stable. The two oxygens are joined by a double bond, however, and breaking that double bond takes a reasonable amount of energy, which is why these reactions are very slow at room temperature. Increasing temperature speeds up most reactions exponentially; this one is no exception.

What if you have two oxygen atoms joined by a single bond, aka a peroxide? Now you’re talking about something a little more dangerous. The two oxygens are unhappy they’re stuck to each other and now they’re only joined by a single bond, which is easier to break. H2O2 is the simplest of the peroxides:

You probably have it in your medicine cabinet, and you probably think of it as pretty harmless. And it is — because the stuff you have in your medicine cabinet is about 3% hydrogen peroxide, 97% water, with some stabilizer to keep the hydrogen peroxide from breaking down too quickly by itself. 10% hydrogen peroxide, by contrast, is corrosive to your skin. 30% hydrogen peroxide has to be handled very carefully, and 70% hydrogen peroxide is extremely dangerous. Another reason why hydrogen peroxide seems so innocuous is because your cells contain an enzyme called catalase that breaks it down very quickly, releasing water and oxygen gas (bubbles!)

You also know peroxides from the hair salon, where chemicals that contain a peroxide group react with the molecules that give your hair its color and thereby bleach it, although they probably damage your hair a little and make it more brittle in the process (more split ends). Or my favorite peroxide: benzoyl peroxide! At high concentration it’s an explosive; at the low concentration in your spot cream, by contrast, you’re reasonably ok (although it will bleach your pillowcase pretty effectively).

Or how about this?

This is sodium hypochlorite, better known as bleach. This molecule is obviously far more stable than say chlorine trifluoride, but it’s still not a very happy partnership; the chlorine would really rather be a chloride ion with a negative charge on it, and the oxygen would rather go find some hydrogen or carbon to hook up with. So it reacts with a wide variety of carbon-based stuff, which is part of the reason why it’s such a brutally effective bacteria-killer, and also part of the reason why it’s good at removing stains from tile and color from your clothes. Most swimming pools are basically very dilute solutions of calcium hypochlorite that has been pH-adjusted down to pH 7.4 or so with some acid. The result is that your pool now contains a mixture of hypochlorite salt and hypochlorous acid:

The hypochlorous acid is an even more brutally effective bacteria-killer than the hypochlorite ion.

Or how about this critter, the nitrate ion?

Nitrate is actually way less reactive than any of these other critters we’ve met so far; nitrogen is a much smaller atom than chlorine, and the bonds that connect it to the oxygen atoms are short and reasonably strong. At room temperature, it doesn’t do much of anything. Many organisms can use it as a source of nitrogen for making amino acids, which is why you find nitrate salts in many of the plants and vegetables you eat. But if you take a concentrated nitrate salt, give it some fuel to react with and a nice push in the form of a spark, it too will blow up. Part of the incentive here is that this reaction will form nitrogen gas, which is extremely stable, and water and carbon dioxide, which are very stable as well. (Nature always wants to go from less stable to more stable in chemical reactions.) Hence gunpowder. Gunpowder is a mixture of potassium nitrate (what used to be called potash) , sulfur and charcoal.

What if — instead of nitrogen in the center of that molecule — you had a chlorine atom? Now you’re talking hideously unstable and violently explosive — and that brings us back to fireworks.

On the left is the chlorate ion; on the right is perchlorate. At first glance perchlorate looks like it should be the more violent of the two, but in fact chlorate is much more dangerous because it takes a lot less effort to get chlorate to lose its cool, and in fact some chlorate-fuel mixtures have been known to detonate rather unpredictably — not a quality you want in a firework (or anything else for that matter). So perchlorate salts are more common in fireworks, although nitrates are used too. The firework is a mixture of the oxidizer (perchlorate, nitrate etc.) with a fuel, a carbon-based compound or less-selfish element that the oxygen from the oxidizing agent can partner with; say aluminum or a magnesium-aluminum alloy for example. The reaction between fuel and oxidizer gives you heat, gas and explosion. A binder like dextrin (starch) holds the fuel and oxidizer together in chunks called stars that scatter from the firework shell casing as it bursts. And the binder also serves as additional fuel.

But what about the colors? That’s the cool part. The colors come from metals, mostly metals in the first two columns of the periodic table like sodium or strontium or barium. All of these metals have either 1 (in the first column) or 2 (in the second column) electrons in their outermost shell, and they badly want to give those outer electrons away; so they’re never found in Nature as the pure metal. Instead they’re found as salts, compounds where the metal has a +1 charge (1st column) or +2 charge (second column) and is paired up with negatively charged ions like chloride to balance the charge out. Most of these salts are considerably more stable and nonreactive; the folks who wanted to give electrons away gave them away, the folks who wanted the electrons got them; everybody’s happy. That’s why the color doesn’t come from a chemical reaction, because the metal ion doesn’t do any reacting; it comes from radiation emitted by the metal ion itself.

As the star explodes it releases a ton of energy as heat. Colliding molecules heat up the metal salt, causing electrons in the metal ions to jump to higher energy levels. The metal ion is now in an “excited state”; it wants to get back to the stable state it was in before. So the electron bounces back down to the lower energy level, releasing that excess energy in the form of radiation. The difference in energy between the higher energy level the electron was at and the energy level it went back to determines the wavelength of the light that’s emitted, and that’s why each element has its own characteristic “emission spectra”, wavelengths of light it emits when heated. Here are sodium, hydrogen and neon gas, for example: Each metal has its own emission spectra, so each metal salt gives a firework a distinctive color; like this: The colors you see in the firework are a lovely illustration of quantum chemistry in action.

Much as we all love fireworks, I have to admit they may not be completely innocuous. For example, there have been some reports that fireworks displays deposit a little leftover perchlorate in the water beneath them, which is interesting because perchlorate is a dangerous carcinogen. Whether this is worthy of concern I don’t know. The paper I cited, for example, looked at perchlorate concentrations in a lake after fireworks displays and found that although concentrations jumped right after the display, they dwindled quickly after that as microorganisms converted the perchlorate to harmless chloride ions and oxygen. (Bacteria that break down perchlorate? Yep, believe it or not. I swear…sometimes it seems like there are bacteria that can break down pretty much anything.) So it’s possible that whether or not this is a problem depends partly on the nature of the local microbial ecosystem, IDK.

Either way…the fireworks this year are gonna be awesome. Get out there and let’s go enjoy watching some noisy, brightly-colored chemistry.