So what should you do if you want to wean yourself off melatonin? Sleep specialists and doctors outlined what you should know about the supplement, and offered a few tips to keep in mind.

Melatonin is a hormone produced primarily in a structure in the brain, called the pineal gland, that regulates the sleep-wake cycle. During the day, the gland does not create melatonin. After the sun sets, darkness triggers it to secrete the hormone, causing drowsiness and other signals that it’s time to sleep.

When you take a melatonin pill, liquid or gummy, “You’re just supplementing what your body is naturally doing anyway,” said Dr. Marri Horvat, a sleep disorder specialist at the Cleveland Clinic.

Some studies have shown that melatonin can help people fall asleep faster and stay asleep longer. But in several clinical trials, supplements were about as effective as a placebo, Dr. Martin said, suggesting that the sleep aid’s power might be partly psychological.

Like most supplements sold in the United States, melatonin isn’t regulated by the U.S. Food and Drug Administration as strictly as prescription or over-the-counter medication — and the amount of melatonin in a pill or gummy can vary drastically, said Dr. Charles A. Czeisler, chief of a division of the Brigham and Women’s Hospital that treats sleep and circadian rhythm disorders.

In general, experts consider melatonin to be safe for short-term use, say, a few nights per week for one to four weeks, Dr. Horvat said. Most people will not experience side effects, she said, although some may feel groggy or lightly “hung over” when they wake up. She typically tells patients to first try taking it once or twice a week to see if it helps.

Doctors know far less about the long-term effects of melatonin. “For almost any medication, whether it’s prescription or over-the-counter, rarely are long-term studies done,” Dr. Gehrman explained. Several reviews have attempted to quantify long-term side effects of melatonin but have found precious little data from rigorous studies.