How does hair spray get out of the can?

Using propellants.

A propellant is a gas or a liquid under pressure. When the pressure is released, the liquid boils or the gas expands, carrying with it any other ingredients. In the case of hair spray, those ingredients are the polymers (basically glue) that hold the hair in place.

But propellants are used to get other things out of spray cans as well. And the contents of the can dictates which propellant is used.

For example, hair spray uses propane, butane, and isobutane as propellants, because the polymers in the spray dissolve easily in butane, which is a liquid under the kind of pressures in the can. Propane also dissolves in butane, so less pressure is needed to contain a lot of propane in the can. The mix of the three propellants is adjusted so that the spray comes out at just the right pressure. Too much propane, and the spray comes out too hard. Too little, and there is not enough force to carry the ingredients to your hair.

The propellant in whipped cream is nitrous oxide (laughing gas). This gas dissolved easily in fats, and is used for cooking sprays and whipped cream. Using a gas that dissolves in the other ingredients in the can allows a lot of gas to be put into the can without using a lot of pressure. When you release the pressure on a can of whipped cream, the cream expands to four times its size in the can.

If air was used, the cream would only whip to half that volume. But air would also allow the cream to go rancid, since it has oxygen in it. Carbon dioxide would dissolve in the water in the cream, but then it would make carbonic acid, which would curdle the proteins in the cream.

Some hair sprays use dimethyl ether or methyl ethyl ether as propellants. These are similar in function to butane, and like butane, are flammable.

Other propellants are pure nitrogen (it doesn’t react with ingredients, but it doesn’t dissolve well, so higher pressures are needed), and hydrofluorocarbons (they liquefy easily, and they are non-flammable, they don’t create smog, and the new ones are safe for the ozone layer).