The compound in St John's wort that can cause photosensitivity in grazing animals is hypericin.
Hypericin is a red, light-sensitive pigment found in Hypericum species, including St John's wort (Hypericum perforatum). When livestock consume enough of the plant, the compound can make unpigmented skin unusually reactive to sunlight. This may lead to reddening, inflammation, blistering, and tissue damage, especially on lightly haired areas.
The reaction is phototoxic rather than a conventional allergy: hypericin absorbs light energy and helps trigger cellular injury in exposed skin. St John's wort is also widely known for herbal preparations marketed for depression, but its chemistry is more complicated than a single “active ingredient.” Hypericin is one constituent, while hyperforin and other compounds also contribute to the plant's biological effects.
A common mix-up is confusing photosensitivity with the plant's possible antidepressant action. The same compound associated with sunlight-related injury in grazing animals is not simply synonymous with all of St John's wort's medicinal effects.