There are three main ways by which food can impact your mood:
Delicious food can make you instantly happier. But that’s often temporary.
Eating healthy can support a fit and healthy body. Having a healthy body is better for your mood than having an unhealthy body.
Certain nutrients in healthy foods can impact your mood for the better.
Magnesium plays many roles in your body, so the potential mechanisms through which it may affect your mood are numerous. We’ll mention two:
Like zinc and vitamin D, magnesium may affect your mood hormonally. Low magnesium is associated with low testosterone,   and low testosterone is associated with low mood in men,     of course, but also in women. 
Magnesium may also affect your brain directly. Preliminary evidence suggests that magnesium modulates the activity of NMDA receptors (a type of glutamate receptors found on neurons),  which would explain why low levels of this mineral can result in abnormal neuronal excitations leading to anxiety.  
Observational studies show that people with anxiety disorders tend to have lower levels of magnesium,   and a systematic review of 18 interventions suggests that supplementation may help people who are susceptible to anxiety.  The reviewers deplore, however, the poor quality of the existing evidence, and in a more recent triple-blind randomized control trial (RCT), supplemental magnesium failed to alleviate postpartum anxiety and depression. 
A 2018 systematic review and meta-analysis concluded that there was little evidence for the involvement of magnesium in depression; it stressed that magnesium supplementation was associated with a decline in symptoms in uncontrolled studies, but not in placebo-controlled studies. 
Magnesium deficiency isn’t unknown in the United States,  especially in the elderly.  Also, since, like zinc, magnesium is lost through sweat,    athletes should take special care of their magnesium intake. Athletes participating in sports requiring weight control seem especially vulnerable to an inadequate magnesium status. 
Fortunately, with just a little care, you can easily reach your Recommended Daily Intake (RDA): magnesium-rich foods are numerous and can fit all kinds of diets. And whereas high doses of supplemental magnesium can cause diarrhea and other gastrointestinal issues, “magnesium, when ingested as a naturally occurring substance in foods, has not been demonstrated to exert any adverse effects”.
If you still feel the need to supplement, at least avoid magnesium oxide: it has poor bioavailability (rats absorbed only 15% in one study,  humans only 4% in another  ) and is more likely to cause intestinal discomfort and diarrhea.
Mixed evidence from observational studies associates low magnesium levels with anxiety but not with depression. Correspondingly, mixed evidence from interventional studies suggests that magnesium supplementation is more likely to help with anxiety than with depression. On a practical level, if you eat enough magnesium-rich foods to satisfy your RDA, as you should, supplementing with magnesium is probably not going to benefit your mood.
A cross-sectional study of data gathered from 14,834 Americans (7,435 women and 7,399 men) between 2009 and 2014 found an association between depression and zinc deficiency.  Likewise, a cross-sectional study of data gathered from 2,019 pregnant Canadian women between 2002 and 2005 reported that being in the highest quintile for zinc intake appeared to buffer the impact of stress and thus the development of depressive symptoms. 
Cross-sectional studies are snapshots in time, though: they might show correlation, but they cannot establish causation. Zinc deficiency was associated with depression, but did it cause the depression? Or did depression cause the zinc deficiency? Or could it be that depression and zinc deficiency were both caused by some other, undetermined factor?
Those are questions cross-sectional studies cannot answer. Fortunately, some randomized trials, which follow people over time, suggest that supplemental zinc makes antidepressant therapies more effective.   
Here again, we don’t yet know all the mechanisms at play. We know that zinc influences the immune system and brain homeostasis, and like magnesium it may act on your brain’s NMDA receptors.  Also, as with magnesium and vitamin D, low zinc levels may impair testosterone production,   and as we saw, low testosterone is associated with low mood in both men     and women. 
If you are not deficient, though, just taking more zinc isn’t likely to help, which might be why, in a recent triple-blind RCT, supplemental zinc failed to alleviate postpartum anxiety and depression.  (The factors leading to postpartum anxiety and depression, it should be noted, may differ substantially from the factors that lead to clinical anxiety and depression in the general population.)
In any case, getting too much zinc is not a good idea. In fact, far overshooting your Recommended Daily Intake (RDA)  can be harmful: in the short term, it can cause nausea  and vomiting;  in the long term, it can lead to a copper deficiency,   which may be inversely associated with depression. 
Still, while overt zinc deficiency is uncommon in the United States, it isn’t entirely unknown. It has notably been documented in people suffering from malabsorption syndromes — including Crohn’s disease, celiac disease, and short-bowel syndrome. Furthermore, even healthy people can have suboptimal levels — especially the elderly.   Finally, since zinc is lost through sweat,  like magnesium, athletes should take special care of their zinc intake. 
Fortunately, zinc-rich foods are not rare. Zinc is mostly found in animal-based foods, but with some planning, vegans can reach their RDAs without resorting to supplementation.
* Adequate Intake (AI)
Low zinc levels are associated with depression. Fortunately, with some planning, you can reach your RDA through foods, even if you’re a vegan. Keep in mind that taking a lot more than your RDA is more likely to harm your health than benefit your mood.
We reviewed the effects of the ever-popular vitamin D on mood in another article. In summary, depression has been associated with vitamin D insufficiency (≤20 ng/mL),   and vitamin D insufficiency is estimated to affect about half the world’s population,   including more than 40% of Americans.  You can have your vitamin D levels assessed through a 25-hydroxyvitamin D blood test.
However, that depression is associated with vitamin D insufficiency doesn’t mean that vitamin D insufficiency is the cause (or the only cause) of the depression. During the winter months, when there is less sun, you might suffer from seasonal affective disorder (SAD),  which has been associated both with a decrease in vitamin D production  (due to a decrease in exposure to the UVB spectrum of sun rays) and with a decrease in illumination    (a decrease in exposure to the visible spectrum of sun rays).
Five successive reviews looked at the effects of supplemental vitamin D on mood. The 2015 review found no significant reduction in depression, though its authors didn’t rule out the possibility that supplemental vitamin D could be more effective in people with higher levels of depression or lower levels of vitamin D than seen in most studies. The four other reviews — published in 2014, 2016, 2017, and 2018 — found benefit from supplementation, but three mentioned low methodological quality,    and two mentioned high risk of publication bias   (of the other two, one found minimal bias  and the other failed to account for bias  ).
In Canada and the United States, the Recommended Daily Allowance (RDA) for vitamin D falls between 400 and 800 IU (International Units).  These amounts, which some researchers criticize as inadequate,    can be obtained naturally from only a few food sources, notably fatty fish (such as salmon, tuna, and sardines). However, in Canada and the United States, milk is often fortified with vitamin D.
Since few foods are rich in vitamin D, supplementation is a valid option. Should your blood test show that your vitamin D levels are low, start supplementing with 2,000 IU/day (a number that, based on the available evidence, should provide the best balance of efficacy and safety), then get tested again after a couple of months.
Low levels of vitamin D (found in more than 40% of Americans) have been associated with depression, and there is preliminary evidence that supplementation can help. Among common foods, fatty fish and fortified milk are the most notable source of vitamin D.
Three large systematic reviews of observational studies and RCTs concluded that fish oil could alleviate clinical depression,   especially when used to complement standard antidepressant therapies.  
Some researchers have stressed, however, that the evidence remains weak — maybe due to the different studies using different designs and methodologies, including different combinations and doses of omega-3 fatty acids   — and that clinical implications should therefore be tempered. 
Essential fatty acids (EFAs) are polyunsaturated fatty acids (PUFAs) your body needs and cannot produce. There are only two kinds of EFAs: linoleic acid (LA) and alpha-linolenic acid (ALA). Neither is very active, so your body transforms the former notably into arachidonic acid (AA) and the latter into eicosapentaenoic acid (EPA) and docosahexaenoic acid (DHA). LA and AA are omega-6 fatty acids, while ALA, EPA, and DHA are omega-3 fatty acids. EPA and DHA make up most of the PUFAs in fish oil.
Several mechanisms of action have been posited to explain the antidepressive effect of PUFAs in general, omega-3 fatty acids, EPA specifically, and DHA specifically,   but on a practical level what stands out is that EPA seems to reduce depression more than DHA does.  
EPA and DHA are mostly found in seafoods, notably fatty fish (such as salmon, tuna, and sardines). The omega-3 fatty acid in most plant foods is ALA, little of which your body converts to EPA and DHA.      For vegetarians and vegans, the only rich source of EPA and DHA is algal oil in supplemental form. 
Preliminary evidence suggests that EPA and DHA, two omega-3 fatty acids abundant in fish oil, can help alleviate clinical depression, especially when they complement standard antidepressant therapies. EPA appears to be more effective than DHA.
Tryptophan is an essential amino acid (EAA), which means that your body needs it but cannot synthesize it and so must get it through food. Your body needs you to consume at least 15 mg of tryptophan per kilogram of body weight per day (15 mg/kg/day, so 6.8 mg/lb/day).
Your body uses tryptophan notably to produce serotonin, a neurotransmitter that helps regulate mood.       A study found that healthy participants fed a diet rich in tryptophan had less anxiety, irritability, and depression. 
It is worth mentioning that, according to some researchers, the total amount of tryptophan ingested is less important than the ratio of tryptophan to other amino acids competing for the same transporter.   If they’re right (although there’s currently little evidence in support of their hypothesis) then just eating a protein-rich diet won’t give you all the mood-benefits of trytophan; you’ll have to prioritize tryptophan-rich foods.
Your body uses tryptophan to produce serotonin, a neurotransmitter known to affect mood. You need to consume at least 15 milligrams of tryptophan per kilogram of body weight per day (so 6.8 mg/lb/day).
A healthy, balanced diet will naturally contain enough magnesium and zinc, two essential minerals likely to affect mood.
Regularly eating fatty fish will provide you with EPA and DHA, two fatty acids that can help alleviate clinical depression. Vegetarians can get their EPA and DHA through conversion of plant fatty acids (though conversion rates can be very low) or through an algal oil supplement.
You can also try selecting foods rich in tryptophan, an amino acid used by your body to produce serotonin, a neurotransmitter known to affect mood.
Finally, if you don’t get enough sun, you might want to consider supplementing with vitamin D.
Related Nutrition Articles
- What is 'roid rage'?
- The myth of the sugar rush
- How can you increase testosterone naturally?
- Does ZMA cause weird dreams?
- Ten tips for better sleep
- When should I take Vitamin D?
- Can vitamin D-crease pain?
- Can vitamin D cure depression?
- Do I need to supplement Vitamin D if I drink fortified milk?
- Should I take Fish Oil if I am sick?
- Can I eat flax seeds instead of fish or fish oil for omega 3s?
- Does fish oil actually help heart health?
- The Interplay between Magnesium and Testosterone in Modulating Physical Function in Men . Int J Endocrinol. (2014) Maggio M, et al.
- Magnesium and anabolic hormones in older men . Int J Androl. (2011) Maggio M, et al.
- Serum testosterone levels and symptom-based depression subtypes in men . Front Psychiatry. (2015) Rodgers S, et al.
- The effect of testosterone levels on mood in men: a review . Psychosomatics. (2013) Johnson JM, Nachtigall LB, Stern TA.
- The benefits and risks of testosterone replacement therapy: a review . Ther Clin Risk Manag. (2009) Bassil N, Alkaade S, Morley JE.
- Testosterone and depression: systematic review and meta-analysis . J Psychiatr Pract. (2009) Zarrouf FA, et al.
- Testosterone in women--the clinical significance . Lancet Diabetes Endocrinol. (2015) Davis SR, Wahlin-Jacobsen S.
- Nutritional supplements in depressive disorders . Actas Esp Psiquiatr. (2017) Martínez-Cengotitabengoa M, González-Pinto A.
- The role of glutamate in anxiety and related disorders . CNS Spectr. (2005) Cortese BM, Phan KL.
- Glutamate and anxiety . Eur Neuropsychopharmacol. (2004) Bergink V, van Megen HJ, Westenberg HG.
- Magnesium intake and depression in adults . J Am Board Fam Med. (2015) Tarleton EK, Littenberg B.
- Magnesium and depression: a systematic review . Nutr Neurosci. (2013) Derom ML, et al.
- The Effects of Magnesium Supplementation on Subjective Anxiety and Stress-A Systematic Review . Nutrients. (2017) Boyle NB, Lawton C, Dye L.
- Effects of zinc and magnesium supplements on postpartum depression and anxiety: A randomized controlled clinical trial . Women Health. (2017) Fard FE, et al.
- Magnesium and mood disorders: systematic review and meta-analysis . BJPsych Open. (2018) Phelan D, et al.
- Update on the relationship between magnesium and exercise . Magnes Res. (2006) Nielsen FH, Lukaski HC.
- A review of magnesium intake in the elderly. A cause for concern? . Magnes Res. (1992) Costello RB, Moser-Veillon PB.
- Relationships between micronutrient losses in sweat and blood pressure among heat-exposed steelworkers . Ind Health. (2016) Tang YM, et al.
- Nutritional Needs in Hot Environments, “Influence of Exercise and Heat on Magnesium Metabolism” . National Academies Press (US). (1993) Institute of Medicine (US) Committee on Military Nutrition Research; Marriott BM, editor. Washington (DC).
- Excretion of sodium, potassium, magnesium and iron in human sweat and the relation of each to balance and requirements . J Nutr. (1963) Consolazio CF, et al.
- Dietary Reference Intakes for Calcium, Phosphorus, Magnesium, Vitamin D, and Fluoride, page 242
- Pharmacokinetic Studies of Orally Administered Magnesium Oxide in Rats . Yakugaku Zasshi. (2017) Yoshimura Y, et al.
- Bioavailability of US commercial magnesium preparations . Magnes Res. (2001) Firoz M, Graber M.
- Association of total zinc, iron, copper and selenium intakes with depression in the US adults . J Affect Disord. (2018) Li Z, et al.
- Higher zinc intake buffers the impact of stress on depressive symptoms in pregnancy . Nutr Res. (2010) Roy A, et al.
- Effects of zinc supplementation in patients with major depression: a randomized clinical trial . Iran J Psychiatry. (2013) Ranjbar E, et al.
- Potential roles of zinc in the pathophysiology and treatment of major depressive disorder . Neurosci Biobehav Rev. (2013) Swardfager W, et al.
- Effect of zinc supplementation on antidepressant therapy in unipolar depression: a preliminary placebo-controlled study . Pol J Pharmacol. (2003) Nowak G, et al.
- Effect of zinc administration on plasma testosterone, dihydrotestosterone, and sperm count . Arch Androl. (1981) Netter A, Hartoma R, Nahoul K.
- Correlation between serum testosterone level and concentrations of copper and zinc in hair tissue . Biol Trace Elem Res. (2011) Chang CS, et al.
- Dietary Reference Intakes for Vitamin A, Vitamin K, Arsenic, Boron, Chromium, Copper, Iodine, Iron, Manganese, Molybdenum, Nickel, Silicon, Vanadium, and Zinc . . () .
- Zinc for the common cold . Cochrane Database Syst Rev. (2011) Singh M, Das RR.
- A randomized controlled trial of the effect of zinc as adjuvant therapy in children 2-35 mo of age with severe or nonsevere pneumonia in Bhaktapur, Nepal . Am J Clin Nutr. (2010) Valentiner-Branth P, et al.
- Zinc-induced copper deficiency: a report of three cases initially recognized on bone marrow examination . Am J Clin Pathol. (2005) Willis MS, et al.
- Fatal copper deficiency from excessive use of zinc-based denture adhesive . Am J Med Sci. (2010) Afrin LB.
- Dietary Reference Intakes for Vitamin A, Vitamin K, Arsenic, Boron, Chromium, Copper, Iodine, Iron, Manganese, Molybdenum, Nickel, Silicon, Vanadium, and Zinc, page 446
- Importance of zinc in the elderly: the ZENITH study . Eur J Clin Nutr. (2005) Meunier N, et al.
- Nutritional needs of seniors . J Am Coll Nutr. (1997) Blumberg J.
- Zinc loss in sweat of athletes exercising in hot and neutral temperatures . Int J Sport Nutr. (1993) Tipton K, et al.
- Vitamin D and depression . J Affect Disord. (2017) Parker GB, Brotchie H, Graham RK.
- Vitamin D: A Narrative Review Examining the Evidence for Ten Beliefs . J Gen Intern Med. (2016) Allan GM, et al.
- Vitamin D: The "sunshine" vitamin . J Pharmacol Pharmacother. (2012) Nair R, Maseeh A.
- Vitamin D deficiency . N Engl J Med. (2007) Holick MF.
- Prevalence and correlates of vitamin D deficiency in US adults . Nutr Res. (2011) Forrest KY, Stuhldreher WL.
- Seasonal Affective Disorder: An Overview of Assessment and Treatment Approaches . Depress Res Treat. (2015) Melrose S.
- Associations between vitamin D levels and depressive symptoms in healthy young adult women . Psychiatry Res. (2015) Kerr DC, et al.
- Seasonal and meteorological associations with depressive symptoms in older adults: A geo-epidemiological study . J Affect Disord. (2016) O'Hare C, et al.
- The efficacy of light therapy in the treatment of mood disorders: a review and meta-analysis of the evidence . Am J Psychiatry. (2005) Golden RN, et al.
- The Can-SAD study: a randomized controlled trial of the effectiveness of light therapy and fluoxetine in patients with winter seasonal affective disorder . Am J Psychiatry. (2006) Lam RW, et al.
- Efficacy of vitamin D supplementation in major depression: A meta-analysis of randomized controlled trials . J Postgrad Med. (2018) Vellekkatt F, Menon V.
- Vitamin D and depression: a systematic review and meta-analysis comparing studies with and without biological flaws . Nutrients. (2014) Spedding S.
- Dietary Reference Intakes for Calcium and Vitamin D . . () .
- Improved Dietary Guidelines for Vitamin D: Application of Individual Participant Data (IPD)-Level Meta-Regression Analyses . Nutrients. (2017) Cashman KD, et al.
- Letter to Veugelers, P.J. and Ekwaru, J.P., A statistical error in the estimation of the recommended dietary allowance for vitamin D. Nutrients 2014, 6, 4472-4475; doi:10.3390/nu6104472 . Nutrients. (2015) Heaney R, et al.
- A statistical error in the estimation of the recommended dietary allowance for vitamin D . Nutrients. (2014) Veugelers PJ, Ekwaru JP.
- Dietary n-3 PUFA, fish consumption and depression: A systematic review and meta-analysis of observational studies . J Affect Disord. (2016) Grosso G, et al.
- Meta-analysis and meta-regression of omega-3 polyunsaturated fatty acid supplementation for major depressive disorder . Transl Psychiatry. (2016) Mocking RJ, et al.
- Fish oil and depression: The skinny on fats . J Integr Neurosci. (2017) Burhani MD, Rasenick MM.
- The efficacy of fish oil supplements in the treatment of depression: food for thought . Transl Psychiatry. (2016) Bastiaansen JA, et al.
- Bioavailability and potential uses of vegetarian sources of omega-3 fatty acids: a review of the literature . Crit Rev Food Sci Nutr. (2014) Lane K, et al.
- Long-chain conversion of 13Clinoleic acid and alpha-linolenic acid in response to marked changes in their dietary intake in men . J Lipid Res. (2005) Hussein N, et al.
- Physiological compartmental analysis of alpha-linolenic acid metabolism in adult humans . J Lipid Res. (2001) Pawlosky RJ, et al.
- Short-term supplementation of low-dose gamma-linolenic acid (GLA), alpha-linolenic acid (ALA), or GLA plus ALA does not augment LCP omega 3 status of Dutch vegans to an appreciable extent . Prostaglandins Leukot Essent Fatty Acids. (2000) Fokkema MR, et al.
- Dietary linoleic acid influences desaturation and acylation of deuterium-labeled linoleic and linolenic acids in young adult males . Biochim Biophys Acta. (1994) Emken EA, Adlof RO, Gulley RM.
- Protein and Amino Acid Requirements in Human Nutrition, page 245, table 49
- Influence of Tryptophan and Serotonin on Mood and Cognition with a Possible Role of the Gut-Brain Axis . Nutrients. (2016) Jenkins TA, et al.
- What has serotonin to do with depression? . World Psychiatry. (2015) Cowen PJ, Browning M.
- Tryptophan depletion and emotional processing in healthy volunteers at high risk for depression . Biol Psychiatry. (2011) Feder A, et al.
- L-Tryptophan: Basic Metabolic Functions, Behavioral Research and Therapeutic Indications . Int J Tryptophan Res. (2009) Richard DM, et al.
- The role of serotonin in human mood and social interaction. Insight from altered tryptophan levels . Pharmacol Biochem Behav. (2002) Young SN, Leyton M.
- The effects of dietary tryptophan on affective disorders . Arch Psychiatr Nurs. (2015) Lindseth G, Helland B, Caspers J.
- Food can lift mood by affecting mood-regulating neurocircuits via a serotonergic mechanism . Neuroimage. (2014) Kroes MC, et al.
- Relationship between plasma ratio of tryptophan to competing amino acids and the response to L-tryptophan treatment in endogenously depressed patients . J Affect Disord. (1980) Møller SE, Kirk L, Honoré P.