If you needed justification for bedtime snacking, we’ve got it. Food can help you get a good night’s sleep.

While there’s a seemingly infinite number of reasons for why you may be having a hard time dozing off, what you’re eating (or rather, what you’re not eating) could be one of them. That’s because there are nutrients in certain foods that have actually been found to promote sleep (and keep you asleep) so that you wake up feeling refreshed. Read on.

The Foods (and Nutrients) that Help You Sleep

In general, foods that can help promote sleep include those that are rich in tryptophan, Vitamins B6 and B3, as well as those high in Omega 3 fats, EPA & DHA. Here’s a detailed list of some foods within those four groups that will bring on the zzz’s.  

1) Seafood

Seafood, including shrimp, lobster, crab, clams, octopus, and seaweed, are some of the best foods to eat before bed. That’s because they’re high in tryptophan, an essential amino acid that our bodies don’t produce on their own. Tryptophan is important for sleep because it’s a precursor to melatonin, which is the sleep-inducing hormone triggered by darkness.

2) Beef

Steak, ground meat, or even beef bone broth is one of the richest sources of omega 3 fats EPA & DHA, which also have been found to trigger the release of melatonin. One study found that these fatty acids are associated with better (and longer) sleep, as they also contribute to reducing anxiety. Vegetarian sources of EPA & DHA include eggs and flax seeds.

3) Sweet potatoes

Sweet potatoes, which are packed with vitamin B6, contribute to metabolizing proteins and fats in your body. They also convert tryptophan to niacin and serotonin, which helps regulate sleep. Other Vitamin B6-rich foods include turkey, chicken, sunflower seeds, spinach, and bananas.

4) Rice

With a high glycemic index and an excellent source of Vitamin B3, rice is one of the foods that helps balance stress-related hormones. Jasmine rice in particular has been found to bring on shut-eye faster. One study found that people who ate Jasmine rice fell asleep faster than when they ate other rice types. Peanuts are another great source of Vitamin B3, which make for a stellar bedtime snack.

5) Kale

Green leafy vegetables, like kale, collards, or spinach, are loaded with calcium, which helps the brain use tryptophan to make melatonin. Other calcium-rich foods, like milk and cheese, would have the same effect.

6) Walnuts

Walnuts are one of the few foods that actually serve as a source of melatonin. Eating walnuts can increase your blood levels of the hormone, helping you sleep more soundly. Other foods containing melatonin include almonds and raspberries.

When to Eat for Sleep

Going to bed on an empty stomach could have some major sleep consequences, as hunger could actually wake you in the middle of the night without you realizing it. At the same time, eating a large meal before bedtime can cause digestive issues that disrupt sleep because your systems slows down and takes longer to process things.

If you’re going to big eat a meal, make sure you have it at least two hours before hitting the hay. And if your meal was more than two hours before sleep, eating a small portion of the foods listed above will keep you satisfied throughout the night.

Foods (and Habits) to Avoid Before Bed

Just as there are foods that calm your brain, there are foods that can stimulate it. And no matter what you eat, there are several bad bedtime habits that will prevent you from getting a good night’s sleep. They include:

1) Caffeine. Caffeine keeps you in the lighter stages of sleep. Even one cup of coffee can cause problems.

2) Alcohol. Alcohol before bedtime causes you to wake up more often, which equals less REM sleep, which is the deepest state of sleep.

3) Tyramine-rich foods. These foods stimulate the brain. They include things like bacon, cheese, and chocolate.

Working Out Helps You Sleep, Too

Along with eating the right foods and avoiding the wrong ones, there’s one more thing that can help ensure you get a good night’s rest—exercise.

Building muscle has been shown to improve the quality of sleep, and it can also help you fall asleep faster, and wake up less frequently throughout the night. Strength-building exercises like shoulder presses, bicep curls, tricep dips, squats, and lunges are all good ones to build the right muscles to make you stronger.

For the best night’s sleep, it’s ideal to get your workout done in the morning. A strenuous workout right before bed could increase your body temperature and make it harder for you to fall asleep.

Alternatively, more relaxing exercises, like yoga or stretching, could put you in just the right relaxed state to doze off peacefully.