Our previous kitchen chemistry post discussed fats and oils, which are “triple esters” of glycerol:
Apart from their role in diet, fats are also used to produce soap:
The soap-making process involves reacting fats with strongly alkaline substances, such as lye (sodium hydroxide, NaOH). This can be done at home, but since lye is dangerous, soap-making is not appropriate for children (see these precautions: 1, 2, 3).
In solution, the lye exists as sodium (Na+) and hydroxide (OH−) ions (indeed, the presence of hydroxide ions is what “alkaline” means). The hydroxide ions react with the fat to free the glycerol:
Fatty acid ions (such as stearate ions, C17H35COO−) are also produced:
Since the sodium ions from the lye still exist, soap is basically sodium stearate, sodium palmitate, or something similar. Because it is the result of reacting a very strongly alkaline substance (sodium hydroxide) with very weak acids (fatty acids), soap itself is also alkaline. This alkaline nature can be harsh on the skin, and especially on the hair. Shampoos are therefore usually made from synthetic detergents, and formulated to be mildly acidic (with a pH between 5 and 7).
Another problem with soap is that it reacts with dissolved calcium, iron, or magnesium ions in hard water, giving an insoluble soap scum of compounds such as magnesium stearate. This can be demonstrated at home by mixing soap solution with a solution of epsom salts (see here or here).