Magnesium is one of the most heavily promoted supplements for sleep. The evidence supporting that use is weak, and you deserve to know that before you spend money on it.
What the evidence shows
The mechanistic argument is reasonable. Magnesium is involved in nervous system regulation and in pathways plausibly related to sleep. Deficiency is associated with poor sleep.
The trial evidence is another matter. The human studies are small, often in older adults or in people who were deficient to begin with, frequently uncontrolled, and inconsistent in their results. There is no large, well-conducted randomised trial showing that magnesium improves sleep in people who are not deficient. That is precisely what a Grade C looks like.
We are keeping this piece on the site rather than ignoring the topic, because you will encounter these claims elsewhere presented with far more confidence than the evidence supports.
How much difference it makes
If you are genuinely deficient, correcting that may well help, along with other things deficiency was affecting. If you are not, the honest expectation is little to nothing beyond placebo, and placebo for sleep is not negligible but it is not what you are being sold.
What to do
Before reaching for magnesium, do the things with better evidence: fix caffeine timing, keep a consistent wake time, get daylight in the morning, and address alcohol. These are Grade A and Grade B interventions and they are free.
If you still want to try magnesium, glycinate and citrate are better absorbed than oxide, which is the cheap form in most supermarket products and the most likely to simply give you loose stools. Try it for a few weeks and judge honestly.
Cautions
Magnesium interferes with the absorption of several drug classes, including some antibiotics, bisphosphonates and thyroid medication. Separate doses by several hours and check with your pharmacist.
If you have reduced kidney function, do not take magnesium supplements without medical advice. Impaired kidneys cannot clear the excess and it can accumulate to dangerous levels.
When to see a doctor
If you suspect deficiency, ask for a test rather than guessing. If your sleep has been poor for months, the cause is worth finding.