Eating a banana before bed can help you fall asleep faster and sleep more soundly. This fruit contains tryptophan, magnesium, potassium, and vitamin B6, which influence the production of sleep hormones and muscle relaxation, according to Verywell Health, citing registered nurse Julie Scott.

Tryptophan is an amino acid from which the brain produces serotonin and melatonin. Serotonin helps you relax, while melatonin regulates sleep cycles. Ripe yellow bananas contain the most tryptophan, while overripe bananas with brown spots contain melatonin.

Magnesium calms muscles and nerves and plays a role in melatonin production, so bananas can help people with a magnesium deficiency relax. Potassium prevents nighttime cramps, and vitamin B6 promotes the production of sleep hormones.

An average banana contains 27 g of carbohydrates, which facilitate the delivery of tryptophan to the brain, and 3 g of fiber. The feeling of fullness provided by fiber helps prevent waking up in the middle of the night due to hunger.

When Is the Best Time to Eat a Banana?

Scott recommends eating a banana one to two hours before bedtime so that your body has time to digest it and absorb its nutrients. This advice is based, in particular, on a study of the effect of banana intake—both in terms of dosage and duration—on sleep disturbances in older adults, published in the Journal of Medical and Allied Sciences.

Nutritionists interviewed by journalists also include bananas on their list of foods that promote better sleep. According to them, in a small study involving 21 people suffering from insomnia, participants slept better when they ate a banana or drank a glass of milk before bed, writes Food & Wine.

Nutritionist Sandra Zhang of Tufts Medical Center points out that it takes about three hours for the stomach to empty, so it’s best to finish eating well in advance. “If you eat and go to bed right away, it can cause acid reflux,” Zhang warns.

Not Just Bananas

Scott emphasizes that you shouldn’t rely solely on bananas. For quality sleep, it’s important to limit screen time in the evening, go to bed at the same time every night, keep the bedroom cool, dark, and quiet, and avoid caffeine in the afternoon. Lack of sleep has been linked to heart disease, high blood pressure, diabetes, and depression.

If you continue to have trouble falling asleep, experts advise consulting a doctor. “If you find that you’re eating well to support sleep and following good sleep hygiene but are still having trouble, it’s worth consulting a sleep medicine specialist,” notes dietitian Jessica Cording.