Several categories of foods can help reduce headache frequency and severity, mostly by supplying nutrients your body needs to regulate inflammation, maintain hydration, and keep blood sugar steady. The most evidence-backed nutrients for headache prevention are magnesium, riboflavin (vitamin B2), and omega-3 fatty acids, all of which are easy to get through everyday foods.
That said, dietary changes aren’t an instant fix. Most experts recommend sticking with a headache-friendly eating pattern for at least three months before judging whether it’s working, though people with frequent headaches may notice improvements sooner.
Magnesium-Rich Foods
Magnesium is one of the most studied nutrients in headache prevention. It plays a role in nerve signaling and blood vessel function, and people who get frequent migraines tend to have lower magnesium levels. The recommended daily intake is 310 to 420 milligrams depending on your age and sex, and many people fall short of that.
The most magnesium-dense foods you can eat are seeds and nuts. Pumpkin seeds lead the pack at 150 mg per ounce, meaning a small handful gets you more than a third of the way to your daily target. Chia seeds deliver 111 mg per ounce, and almonds provide 80 mg. Cashews (72 mg per ounce) and peanuts (49 mg per ounce) are solid options too.
Cooked dark leafy greens are another reliable source. Half a cup of cooked spinach contains 78 mg, and Swiss chard is close behind at 75 mg. Black beans and quinoa each provide about 60 mg per half cup. Even dark chocolate (70% cocoa or higher) contributes 64 mg per ounce, which is a reasonable excuse to keep some on hand.
You don’t need to overhaul your diet to hit your target. Adding pumpkin seeds to oatmeal, snacking on almonds, and eating a serving of leafy greens at dinner can easily add 200 to 300 mg on top of what you’re already getting from other foods.
Foods High in Riboflavin (Vitamin B2)
Riboflavin helps your cells produce energy, and at higher doses it appears to reduce migraine frequency. In a randomized trial, adults who took 400 mg of riboflavin daily experienced two fewer migraine attacks per month compared to those on a placebo. The Canadian Headache Society recommends that same 400 mg dose for migraine prevention, noting that side effects are minimal (mostly yellow-tinted urine).
Reaching 400 mg through food alone is difficult, since even the richest sources contain only a few milligrams per serving. But building a riboflavin-rich diet still helps. The best food sources are eggs, lean meats, organ meats (especially liver), and milk. In the U.S., bread, cereals, and other grain products are fortified with riboflavin, making them meaningful contributors to daily intake. If you get frequent migraines and want to try the clinical dose, a supplement is the practical route, but a diet rich in these foods provides a baseline.
Omega-3 Fatty Acids
Omega-3 fats have anti-inflammatory properties that are directly relevant to headache pain. Your body converts them into specialized compounds that help resolve inflammation and reduce pain signaling. This is the opposite of what omega-6 fats (common in processed and fried foods) tend to do, which is promote inflammation. Shifting your diet to include more omega-3s and fewer omega-6s can tilt that balance in your favor.
The best food sources are oily fish: salmon, mackerel, sardines, herring, trout, and tuna. Eating these two to three times per week is a reasonable target. Plant-based sources include walnuts, flaxseed, and chia seeds (which pull double duty as magnesium sources). Leafy greens and legumes contain smaller amounts.
Hydrating Foods and Fluids
Dehydration is one of the most straightforward headache triggers. When your body loses too much fluid, your brain actually shrinks slightly and pulls away from the skull, putting pressure on surrounding nerves. That pressure is what you feel as a dull, aching headache.
The baseline recommendation is six to eight glasses of water per day, roughly 1.5 to 2 liters. If you’re sweating heavily from exercise or heat, a low-sugar electrolyte drink can help replace what you’re losing. Many commercial sports drinks are loaded with sugar, so check the label.
Water-rich foods also count toward your fluid intake. Watermelon, cucumbers, oranges, strawberries, and celery are all above 90% water by weight. Soups and broths contribute both fluid and electrolytes. If you find yourself getting headaches in the afternoon, dehydration is one of the first things worth ruling out.
Steady Blood Sugar, Fewer Headaches
Skipping meals or eating a lot of sugar on an empty stomach can cause your blood sugar to spike and then crash. That crash, called reactive hypoglycemia, directly triggers headaches in many people. The fix is straightforward: eat balanced meals and snacks roughly every three hours, and favor foods that release energy slowly.
Whole grains like oats, brown rice, and whole wheat bread are good anchors. Pairing them with protein or healthy fat (peanut butter on whole grain toast, for example) slows digestion further and keeps blood sugar stable. Fruits, vegetables, and legumes are high in fiber and have the same steadying effect. The foods to limit are sugary snacks, white bread, white pasta, and other processed simple carbohydrates, especially when eaten alone.
Ginger
Ginger has a long reputation as a headache remedy, and there’s some clinical support for it. A small comparison trial found that ginger performed similarly to sumatriptan, a common migraine medication, for acute relief. The evidence is limited, but given that ginger is inexpensive and well-tolerated, it’s worth trying. Fresh ginger steeped in hot water as a tea is the simplest approach. Grating it into soups, stir-fries, or smoothies works too.
Caffeine: Helpful in Small Doses
Caffeine has a complicated relationship with headaches. In small amounts, it narrows blood vessels and can relieve headache pain, which is why it’s an ingredient in many over-the-counter pain relievers. But too much caffeine becomes a trigger. Research from Harvard found that three or more caffeinated drinks in a day was associated with higher odds of a migraine on that day or the next. One to two servings showed no increased risk.
If you drink coffee or tea, keeping it to one or two cups a day appears to be the safe zone. Consistency matters too. Your body adapts to regular caffeine intake, and abruptly cutting back can cause withdrawal headaches that last several days.
Foods That Commonly Trigger Headaches
Knowing what to eat is only half the picture. Certain compounds in food can trigger headaches in susceptible people, though the American Headache Society estimates that only about 10% of migraine sufferers are genuinely sensitive to food triggers. The relationship between diet and migraine is, in their words, “vastly misunderstood.” Still, if you notice a pattern, it’s worth investigating.
The main culprits are:
- Tyramine, found in aged cheeses (cheddar, brie, blue, parmesan, gouda, Swiss, and others), cured and processed meats (pepperoni, salami, hot dogs, jerky, bologna), and fermented or pickled foods like sauerkraut and pickles.
- Nitrates and nitrites, used as preservatives in deli meats, sausages, bacon, and hot dogs.
- Fresh yeast products, including fresh-baked bread, bagels, doughnuts, and sourdough. Interestingly, freezing these products may deactivate the yeast enough to reduce the trigger effect.
- Alcohol, particularly red wine and beer, which contain both tyramine and histamine.
If you suspect a food trigger, an elimination diet is the standard approach: remove the suspected foods for at least three months, then reintroduce them one at a time to see if headaches return. Keeping a food diary alongside a headache log makes the pattern much easier to spot. Many people discover their actual triggers are different from what they assumed, or that food isn’t the issue at all.
Putting It Together
A headache-friendly diet isn’t a radical overhaul. It looks a lot like general healthy eating: plenty of vegetables, whole grains, nuts, seeds, and fatty fish. Consistent meals to keep blood sugar steady. Enough water throughout the day. The specific additions that target headaches are boosting magnesium (seeds, leafy greens, dark chocolate), eating riboflavin-rich foods (eggs, dairy, lean meat), including omega-3 sources regularly (fatty fish, walnuts, flaxseed), and keeping caffeine moderate.
Give any dietary changes at least a few months before deciding they aren’t working. Headache patterns fluctuate naturally, and it takes time to separate real improvement from normal variation.

