Vitamin D is produced photochemically from 7-dehydrocholesterol in the skin of most vertebrate animals, including humans. The precursor of vitamin D, 7-dehydrocholesterol is produced in relatively large quantities. 7-Dehydrocholesterol reacts with UVB light at wavelengths of 290–315 nm. These wavelengths are present in sunlight, as well as in the light emitted by the UV lamps in tanning beds (which produce ultraviolet primarily in the UVA spectrum, but typically produce 4% to 10% of the total UV emissions as UVB, some tanning beds can use only separate UVB light bulbs specifically for vitamin D production). Exposure to light through windows is insufficient because glass almost completely blocks UVB light.
Adequate amounts of vitamin D can be produced with moderate sun exposure to the face, arms and legs (for those with the least melanin), averaging 5–30 minutes twice per week, or approximately 25% of the time for minimal sunburn. The darker the skin on the Fitzpatrick scale and the weaker the sunlight, the more minutes of exposure are needed. It also depends on parts of body exposed, all three factors affect minimal erythema dose (MED). Vitamin D overdose from UV exposure is impossible: the skin reaches an equilibrium where the vitamin D degrades as fast as it is created.
The skin consists of two primary layers: the inner layer called the dermis, and the outer, thinner epidermis. Vitamin D is produced in the keratinocytes of two innermost strata of the epidermis, the stratum basale and stratum spinosum, which also are able to produce calcitriol and express the VDR.