As onions are sliced, cells are broken, allowing enzymes called alliinases to break down amino acid sulphoxides and generate sulphenic acids.
A specific sulfenic acid, 1-propenesulfenic acid, formed when onions are cut, is rapidly rearranged by a second enzyme, called the lachrymatory factor synthase, giving syn-propanethial-S-oxide a volatile gas known as the onion lachrymatory factor (LF).
The LF gas diffuses through the air and eventually reaches the eye, where it activates sensory neurons, creating a stinging sensation. Tear glands produce tears to dilute and flush out the irritant. Chemicals that exhibit such an effect on the eyes are known as lachrymatory agents.
Supplying ample water to the reaction while peeling onions prevents the gas from reaching the eyes. Eye irritation can, therefore, be avoided by cutting onions under running water or submerged in a basin of water.
Another way to reduce irritation is by chilling, or by not cutting off the root of the onion (or by doing it last), as the root of the onion has a higher concentration of enzymes.