Your body makes melatonin through a four-step chemical conversion that starts with tryptophan, an amino acid you get from food. The process happens primarily in the pineal gland, a pea-sized structure deep in your brain, and it’s tightly controlled by light exposure. When darkness falls, a signaling chain from your eyes to your brain unlocks production; when light returns, it shuts down. Here’s how each piece of that process works.
From Tryptophan to Melatonin in Four Steps
Melatonin production begins with L-tryptophan, the same amino acid found in turkey, eggs, nuts, and dairy. Your body can’t make tryptophan on its own, so your diet is the ultimate raw material for melatonin. Once tryptophan reaches the pineal gland, four enzymatic reactions transform it into melatonin.
First, an enzyme adds a chemical group to tryptophan, converting it into 5-hydroxytryptophan. Second, another enzyme strips off a piece of that molecule (releasing carbon dioxide in the process) to produce serotonin. Serotonin is the well-known mood-related chemical, and it serves as the direct precursor to melatonin.
Third, and most critically, an enzyme called AANAT attaches an acetyl group to serotonin, creating N-acetylserotonin. This is the rate-limiting step, the slowest reaction in the chain and the one that controls how much melatonin you ultimately produce. AANAT activity rises and falls with the light-dark cycle, which is why it’s sometimes called the “melatonin rhythm enzyme.” Fourth and finally, a methyltransferase enzyme adds a methyl group to N-acetylserotonin, yielding melatonin.
Several nutrients act as cofactors in this chain. B vitamins (particularly B6 in its active form), iron, magnesium, and vitamin D all play supporting roles in serotonin synthesis. A deficiency in any of these can, in theory, limit the raw materials available for melatonin production downstream.
How Light Controls the Entire Process
The pineal gland doesn’t decide on its own when to make melatonin. It takes orders from your eyes, relayed through a surprisingly long neural circuit. A small subset of cells in your retina contain a light-sensitive pigment called melanopsin. These cells don’t help you see images. Instead, they detect ambient brightness and send that information to the suprachiasmatic nucleus (SCN), a tiny cluster of neurons in the brain that acts as your master biological clock.
When the SCN detects light, it releases an inhibitory signal that blocks the downstream chain to the pineal gland. Melatonin production stops. When darkness arrives, the SCN switches to an excitatory signal that travels a roundabout path: from the hypothalamus down into the upper spinal cord, back up to a nerve cluster in the neck (the superior cervical ganglion), and finally into the pineal gland via sympathetic nerve fibers that release norepinephrine. That norepinephrine activates AANAT, the rate-limiting enzyme, and melatonin synthesis ramps up.
Blue light is the most potent suppressor. Melanopsin is most sensitive to short-wavelength light around 464 nanometers, squarely in the blue portion of the visible spectrum. In one controlled study, after two hours of blue light exposure at 80 lux (roughly the brightness of a dimly lit room), melatonin levels measured just 7.5 pg/mL. Under red light at the same brightness, melatonin reached 26.0 pg/mL, more than three times higher. Current guidelines suggest keeping light below 10 melanopic lux in the three hours before bedtime and below 1 melanopic lux during sleep.
When Production Starts and Peaks
In young adults, melatonin secretion typically begins around 9:30 to 10:00 PM under dim light conditions. Researchers call this the “dim light melatonin onset,” or DLMO, and it’s the most reliable marker of your internal clock’s timing. Daytime blood levels of melatonin hover around 1 to 2 pg/mL, essentially trace amounts. Once the DLMO kicks in, levels climb past 10 pg/mL and continue rising through the night.
The timing shifts with age. Children under 10 tend to have the earliest onset, while people around age 20 have the latest. After that, onset gradually moves earlier again, shifting by about 30 minutes in older adults compared to 20-year-olds. Production winds down in the early morning hours as light exposure resumes, a phase researchers call the “dim light melatonin offset.”
How Production Changes With Age
Melatonin production follows a dramatic arc across the human lifespan. Newborns produce almost no melatonin before three months of age. Production then ramps up quickly, reaching its all-time peak between ages one and three. From that childhood peak through the rest of adolescence, nocturnal melatonin levels drop by roughly 80%.
That steep childhood decline isn’t necessarily because the pineal gland is failing. It’s likely a dilution effect: the body grows much larger while the pineal gland’s output stays relatively constant, so the concentration in the blood falls. In adulthood, levels remain fairly stable until old age, when an additional decline of about 10% occurs. This late-life drop appears to involve a different mechanism tied to aging itself, though exactly what drives it remains unclear. The overall pattern helps explain why sleep architecture changes so noticeably from childhood through older age.
The Pineal Gland Isn’t the Only Source
While the pineal gland gets most of the attention, it’s not your only melatonin factory. Your gastrointestinal tract, retina, and immune cells all produce melatonin independently. The gut is by far the largest extrapineal source. Melatonin concentrations in the GI tract can reach levels 400 times greater than what’s found in the blood from pineal production alone.
Gut melatonin doesn’t follow the same light-dark cycle as pineal melatonin. It appears to act locally, influencing digestion and protecting the gut lining rather than regulating sleep. This is why removing the pineal gland in animal studies eliminates the nighttime rise in blood melatonin but doesn’t wipe out melatonin from the body entirely.
How Supplement Melatonin Is Made
The melatonin in supplements is almost entirely synthetic, produced through chemical manufacturing rather than extracted from animal tissue. The standard industrial process starts with simple chemical building blocks (phthalimide and a brominated compound) and builds the melatonin molecule in about four steps. The end product is chemically identical to what your pineal gland produces.
Researchers are also exploring microbial fermentation as an alternative. By engineering bacteria like E. coli to express the same enzymes used in the natural pathway (particularly AANAT and the final methyltransferase), scientists have successfully produced melatonin in laboratory settings. The appeal is a more sustainable, greener process compared to traditional chemical synthesis, which relies on petrochemical-derived starting materials. For now, though, commercially available melatonin supplements still depend on the synthetic chemical route.

