Vitamin D2 is a synthetic form of vitamin D. It is made by extracting ergosterol from fungi and then exposing it to ultraviolet light. In the human body, the precursor chemical that exists in our skin and becomes vitamin D3 in the sun (no sunscreen) is cholesterol. Ergosterol is therefore a fungal equivalent of cholesterol. Although it has been shown that vitamin D2 functions very similarly to vitamin D3.
In the 1920s, a process was developed to convert ergosterol from fungi to ultraviolet light and produce vitamin D2. This is a cheap and easy way to produce vitamin D and has become the main method of producing vitamin D. This vitamin D can be supplemented before newer methods can produce vitamin D3 for human use. Most studies have shown that vitamin D2 is slightly less potent than vitamin D3, but can also provide the same benefits as vitamin D3 if taken in large doses.