For hair coloring products intended to last more than 12 washes, the two main chemical ingredients are hydrogen peroxide and ammonia. Semi-permanent dyes use ammonia, but they usually contain a lesser amount than permanent dye and may use the chemical p-phenylenediamine.
Ammonia, one of the most common chemicals in hair dye products, opens up hair cuticles. When mixed with the coloring product, the ammonia allows the color to enter deep into the hair follicles and interact with the melanin in the hair. Melanin, the substance responsible for the natural color of hair, is changed by the ammonia and dye combination, which accordingly changes the color of the hair.
When mixed with ammonia and coloring, hydrogen peroxide causes the hair to swell. This swelling lets the ammonia carry the hair coloring into the follicles more efficiently. Hydrogen peroxide can damage the hair by causing it to lose sulfur. This can result in hard, damaged hair, and more damage occurs with greater concentrations of hydrogen peroxide.
Temporary dyes such as sprays and rinses only deposit a temporary color pigment onto the hair shaft. These types of dyes or washes do not penetrate the hair cuticle. Instead the hair only absorbs the color into its shaft, and it goes away following the hair's next wash.
Alternatively, those who wish to avoid the chemicals in commercial hair dye products can choose to use dyes that do not contain harsh chemicals. Some hair dyes with reduced chemicals use herbal-based coloring for dye as opposed to ammonia.