It is after midnight, you are still awake, and suddenly the refrigerator starts looking tempting. A slice of pizza or a bowl of ice cream may sound harmless. Yet what you eat close to bedtime can affect how your stomach feels and how well you sleep.
The clock itself is not the main issue. Eating at 12:05 a.m. is not automatically worse than eating at 11:55 p.m. What counts is how close you eat to the time you lie down.

For people who get heartburn at night, the National Institute of Diabetes and Digestive and Kidney Diseases recommends eating meals at least three hours before lying down.
So, if you are hungry late at night, some choices are better left for daytime.
1. Pizza
Pizza is one of the first foods to avoid when you are about to go to bed.
Most pizza combines cheese, fatty meat, tomato sauce, and a large amount of refined flour. Fatty and acidic foods can trigger heartburn in some people, especially when they lie down soon after eating.
A large serving may also leave you feeling overly full when you are trying to sleep.
If you are truly hungry, choose something smaller instead of eating several slices right before bed.
2. Fried Foods
French fries, fried chicken, onion rings, and other greasy foods are poor late-night choices.
High-fat foods are commonly linked with worsening heartburn. They can also make some people feel bloated or uncomfortably full.
That heavy feeling is the last thing you want when you are trying to settle into bed.
Save fried foods for earlier in the day and keep nighttime meals lighter.
3. Spicy Foods
Hot wings, spicy noodles, chili, and foods covered in hot sauce can be troublesome before sleep.
Spicy foods are common heartburn triggers. If you already notice burning in your chest or throat after spicy meals, eating them shortly before lying down may make the problem worse.1
Not everyone reacts to spicy food in the same way. Pay attention to what happens after you eat it.
4. Chocolate
Chocolate may seem like a small bedtime treat, but it can cause problems for some people.
Chocolate is one of the foods commonly linked with heartburn symptoms. It also contains caffeine, although the amount varies by the type of chocolate.
Caffeine can stay in the body for hours and interfere with sleep, particularly in people who are sensitive to it.
Dark chocolate tends to contain more caffeine than milk chocolate, so a large serving late at night may not be the best choice.2
5. Cakes, Cookies, and Sugary Cereal
A bowl of sugary cereal or several cookies can be hard to resist when you are awake late.
However, foods high in added sugar provide plenty of calories without offering the same nutrition as whole foods. Regularly eating too much added sugar is linked with weight gain, type 2 diabetes, and heart disease.
Refined grains and sugary foods can also raise blood sugar faster than foods containing more fiber and protein.
If late-night sweets have become a daily habit, changing that habit may support your long-term health.
6. Tomato-Based Foods
Tomato sauce, pasta with red sauce, salsa, and similar foods can cause nighttime discomfort in people who are prone to heartburn.
Tomatoes are acidic, and acidic foods are among the common triggers reported by people with acid reflux.
This does not mean tomatoes are unhealthy. The timing may simply be a problem if you eat them shortly before lying down.
What About Coffee and Alcohol?
What you drink late at night deserves attention too.
Coffee, energy drinks, and other caffeinated drinks can make it harder to sleep. Caffeine may affect sleep even when consumed several hours before bedtime.
Alcohol may make you sleepy at first, but it can lead to lighter sleep and more waking during the night.3
If You Are Hungry After Midnight
You do not have to go to bed hungry.
A small snack may be reasonable, especially if you have not eaten for several hours. Eating before bed is not harmful for everyone, and a light snack may be easier on your body than a large meal.
Try a small serving of plain yogurt, a banana with a few nuts, or a piece of whole-grain toast.
The foods you should not eat after midnight are mainly the ones that leave you too full, trigger heartburn, contain caffeine, or add large amounts of sugar to your diet. If nighttime eating keeps causing heartburn, stomach pain, or poor sleep, talk with your doctor.