Melatonin is best known as a sleep hormone, but most of the body's melatonin isn't made in the brain at all. It's produced in the gut lining, in amounts many times higher than what the pineal gland makes for sleep. Gut melatonin plays a separate, local role in regulating motility, the speed at which food moves through the digestive tract.
A meta-analysis of four randomized controlled trials, 115 participants total, tested oral melatonin supplements, in doses of 3 to 5 milligrams, against placebo in people with IBS.[1] Melatonin meaningfully improved overall IBS severity and abdominal pain compared with placebo, and quality-of-life scores improved as well. It made no measurable difference to bloating or sleep quality in this analysis, which is a useful reminder that melatonin's gut effect here is separate from any sedative effect.
What to do with this
If IBS pain and overall severity are your main complaints, and constipation isn't a dominant symptom, consider the trial evidence. It supports 3 to 5 milligrams of melatonin, taken in the evening, as a reasonable option to discuss with a doctor. Benefits are generally assessed after 8 or more weeks of use. Other supplements sometimes tried for gut symptoms, like magnesium, NAC, and creatine, work through entirely different mechanisms, so effects don't necessarily transfer. If constipation-predominant IBS is your main pattern, raise this specific caution with your doctor before starting, since melatonin's effect on motility could work against you. Melatonin is not established as a general digestion aid for people without diagnosed IBS.