The short answer is Yes. The longer answer is: It’s complicated.
Sleeping pills work for some people at some times. In this respect they are no different from other drugs.
Different medicines work on different neurochemical systems – benzodiazepines and z-drugs work to promote the GABA system, and antihistamines antagonize the histamine system. Suvorexant antagonizes the orexin system, and melatonin and its agonists have their own hormonal system for promoting sleep. Some drugs might work great for some insomniacs while another class of medicine does close to nothing.
Dosage and timing are also factors. The discipline of pharmacokinetics that is about how fast and how long drugs work in the body. See our page on the kinetics of sleep medicine.
Getting to the answer of whether drugs work in general is difficult, because even experienced doctors have a limited number of patients who have used these drugs, doctors don’t formally follow-up to see if the drugs work, other factors go into sleep quality and duration, and the insomnia may disappear even without medication. It’s very complex, and separating out the efficacy of drugs is difficult. A meta-study of randomized controlled trials concluded benzodiazepines, z-drugs, and antidepressants can help patients with chronic insomnia, although there are risks
Further, formal clinical studies on the question sometimes suffer, as do many studies from publication bias and inadequate experimental design. The FDA will not approve drugs to be sold in the US for a given "indication" (i.e. disease or illness) unless there is some proof the drug works for that indication, at least for some patients. Drug companies sponsor these trials for their products, but once the medicine is approved, follow-up tests are less common.
The authors concluded:
"Compared with placebo, Z drugs produce slight improvements in subjective and polysomnographic sleep latency, especially with larger doses and regardless of type of drug. Although the drug effect and the placebo response were rather small and of questionable clinical importance, the two together produced to a reasonably large clinical response."
So here’s the answer from that study:
1) Placebos work some. If you think a sleeping pill will work, it is more likely to work and human psychology works such that a pill with no active drug can still result in better sleep. The effect is generally thought to be small, but recent research found increases in cognitive test scores among people who had taken placebos believing they were sleeping pills.
2) Z-drugs work better than placebos in getting people to sleep and keeping them asleep. The effect is small.
3) If you combine the small effects from (1) and (2), you have a large enough effect to be clinically useful.
Antihistamines are sold for other reasons than insomnia, and there have been no recent studies on their efficacy for inducing sleep. However, back in the 1970s they were shown to be effective enough that the FDA approved them to be sold as sleeping aids. Diphenhydramine, which is the active ingredient in over-the-counter pills, has been shown to increase sleepiness in a segment of the population. It might work for you, and it might not.
While we discourage people from taking sleeping pills unless they really have to, we recognize that they can be an effective technology that help many. If you take these medicines and they work for you, remember: just because your sleep improves doesn’t mean the pills are the magic bullet for insomnia. Other factors may have come into play and it is possible that your insomnia would have improved on its own. Always maintain a critical attitude and keep a sleep diary to try to sort out whether the drugs truly are working.
The standard recommendation is generally to take the sleeping pill 30 minutes before bedtime. Consult the label on the medication or your doctor for specific instructions for you. Korean scientists found that patient satisfaction was improved if the time between pill ingestion and wake-up time was shortened. They recommend doctors tell their patients to take the pill 7 hours before they intend to get out of bed in the morning.