Your skin makes a UV absorber of its own: melanin, the pigment that colours skin, hair and eyes.
Melanin is made by cells called melanocytes, at the bottom of the outer layer of skin. They build it from tyrosine, the amino acid your body also turns into dopamine. An enzyme called tyrosinase, a close relative of polyphenol oxidase, the enzyme that browns a cut apple, adds a second -OH group to tyrosine's ring, making levodopa, also called L-DOPA.
Drag the model to turn it. Pinch to zoom, or use the buttons.
Tyrosinase then takes the hydrogen from both -OH groups, turning them into C=O groups, just as polyphenol oxidase makes quinones in the apple. After a few more steps the products join up into large melanin molecules, the same family of brown molecules that colours a browned apple. Melanin is a tangled network of rings with alternating double bonds running through it. It absorbs light right across the UV and the visible colours, most strongly in the UV, so it looks brown or black. Like a sunscreen molecule, it turns almost all the energy it absorbs into heat.
Skin makes two main kinds. Eumelanin is brown to black. Pheomelanin holds sulfur as well and is red to yellow; it gives red hair its colour.
A cap over the DNA
Melanocytes pack melanin into tiny packets and pass them along their long arms to the skin cells around them. Inside each skin cell, the packets gather in a cap over the nucleus, on the side facing the surface, and shade the DNA from above.
Skin colour and tanning
People of every skin colour have about the same number of melanocytes. Darker skin makes more melanin, mostly eumelanin, in bigger packets, so more UV is absorbed before it reaches the DNA.
After time in the sun, melanocytes make more melanin over the next few days: a tan. Tanning is set off by UV damage to the DNA in skin cells, so a tan is a sign of damage already done. The extra melanin protects about as well as a sunscreen of SPF 3 or 4.