Most of us know that junk food is unhealthy. We know that poor nutrition is related to heart problems, high blood pressure, and a host of other health ailments. You might even know that studies show that eating junk food has been linked to increases in depression.

But if it’s so bad for us, why do we keep doing it?

There is an answer. And the science behind it will surprise you.

Why We Crave Junk Food

Steven Witherly is a food scientist who has spent the last 20 years studying what makes certain foods more addictive (and tasty) than others. Much of the science that follows is from his excellent report, “Why Humans Like Junk Food.”

According to Witherly, when you eat tasty food, there are two factors that make the experience pleasurable.

First, there is the sensation of eating the food. This includes what it tastes like (salty, sweet, umami, etc.), what it smells like, and how it feels in your mouth. This last quality — known as “orosensation” — can be particularly important. Food companies will spend millions of dollars to discover the most satisfying level of crunch in a potato chip. Their scientists will test for the perfect amount of fizzle in a soda. These factors all combine to create the sensation that your brain associates with a particular food or drink.

The second factor is the actual macronutrient makeup of the food — the blend of proteins, fats, and carbohydrates that it contains. In the case of junk food, food manufacturers are looking for a perfect combination of salt, sugar, and fat that excites your brain and gets you coming back for more.

Here’s how they do it…

How Science Creates Cravings

There are a range of factors that scientists and food manufacturers use to make food more addictive.

Dynamic contrast. Dynamic contrast refers to a combination of different sensations in the same food. In the words of Witherly, foods with dynamic contrast have:

… an edible shell that goes crunch followed by something soft or creamy and full of taste-active compounds. This rule applies to a variety of our favorite food structures — the caramelized top of a creme brulee, a slice of pizza, or an Oreo cookie — the brain finds crunching through something like this very novel and thrilling.

Salivary response. Salivation is part of the experience of eating food, and the more that a food causes you to salivate, the more it will swim throughout your mouth and cover your taste buds. For example, emulsified foods like butter, chocolate, salad dressing, ice cream, and mayonnaise promote a salivary response that helps to lather your taste buds with goodness. This is one reason why many people enjoy foods that have sauces or glazes on them. The result is that foods that promote salivation do a happy little tap dance on your brain and taste better than ones that don’t.

Rapid food meltdown and vanishing caloric density. Foods that rapidly vanish or “melt in your mouth” signal to your brain that you’re not eating as much as you actually are. In other words, these foods literally tell your brain that you’re not full, even though you’re eating a lot of calories.

I brought him two shopping bags filled with a variety of chips to taste. He zeroed right in on the Cheetos. “This,” Witherly said, “is one of the most marvelously constructed foods on the planet, in terms of pure pleasure.” He ticked off a dozen attributes of the Cheetos that make the brain say more. But the one he focused on most was the puff’s uncanny ability to melt in the mouth. “It’s called vanishing caloric density,” Witherly said. “If something melts down quickly, your brain thinks that there’s no calories in it … you can just keep eating it forever.”

Sensory specific response. Your brain likes variety. When it comes to food, if you experience the same taste over and over again, then you start to get less pleasure from it. In other words, the sensitivity of that specific sensor will decrease over time. This can happen in just minutes.

Junk foods, however, are designed to avoid this sensory specific response. They provide enough taste to be interesting (your brain doesn’t get tired of eating them), but it’s not so stimulating that your sensory response is dulled. This is why you can swallow an entire bag of potato chips and still be ready to eat another. To your brain, the crunch and sensation of eating Doritos is novel and interesting every time.

Calorie density. Junk foods are designed to convince your brain that it is getting nutrition, but to not fill you up. Receptors in your mouth and stomach tell your brain about the mixture of proteins, fats, carbohydrates in a particular food, and how filling that food is for your body. Junk food provides just enough calories that your brain says, “Yes, this will give you some energy,” but not so many calories that you think, “That’s enough, I’m full.” The result is that you crave the food to begin with, but it takes quite some time to feel full from it.

Memories of past eating experiences. This is where the psychobiology of junk food really works against you. When you eat something tasty (say, a bag of potato chips), your brain registers that feeling. The next time you see that food, smell that food, or even read about that food, your brain starts to trigger the memories and responses that came when you ate it. These memories can actually cause physical responses like salivation and create the “mouth-watering” craving that you get when thinking about your favorite foods.

All of this brings us to the most important question of all.

Food companies are spending millions of dollars to design foods with addictive sensations. What can you and I do about it? Is there any way to counteract the money, the science, and the advertising behind the junk food industry?

How to Kick the Junk Food Habit and Eat Healthy

The good news is that the research shows that the less junk food you eat, the less you crave it. My own experiences have mirrored this. As I’ve slowly begun to eat healthier, I’ve noticed myself wanting pizza and candy and ice cream less and less. Some people refer to this transition period as “gene reprogramming.”

Whatever you want to call it, the lesson is the same: If you can find ways to gradually eat healthier, you’ll start to experience the cravings of junk food less and less. I’ve never claimed to have all the answers (or any, really), but here are three strategies that might help.

1. Use the “outer ring” strategy and the “5 ingredient rule” to buy healthier food.

The best course of action is to avoid buying processed and packaged foods. If you don’t own it, you can’t eat it. Furthermore, if you don’t think about it, you can’t be lured by it.

We’ve talked about the power of junk food to pull you in and how memories of tasty food in the past can cause you to crave more of it in the future. Obviously, you can’t prevent yourself from ever thinking about junk food, but there are ways to reduce your cravings.

First, you can use my “outer ring” strategy to avoid processed and packaged foods at the grocery store. If you limit yourself to purchasing foods that are on the outer ring of the store, then you will generally buy whole foods (fruits, vegetables, meat, eggs, etc.). Not everything on the outer ring is healthy, but you will avoid a lot of unhealthy foods.

You can also follow the “5 ingredient rule” when buying foods at the store. If something has more than 5 ingredients in it, don’t buy it. Odds are, it has been designed to fool you into eating more of it. Avoid those products and stick with the more natural options.

2. Eat a variety of foods.

As we covered earlier, the brain craves novelty.

While you may not be able to replicate the crunchy/creamy contrast of an Oreo, you can vary your diet enough to keep things interesting. For example, you could dip a carrot (crunchy) in some hummus (creamy) and get a novel sensation. Similarly, finding ways to add new spices and flavors to your dishes can make eating healthy foods a more desirable experience.

Moral of the story: Eating healthy doesn’t have to be bland. Mix up your foods to get different sensations and you may find it easier than eating the same foods over and over again. (At some point, however, you may have to fall in love with boredom.)

3. Find a better way to deal with your stress.

There’s a reason why many people eat as a way to cope with stress. Stress causes certain regions of the brain to release chemicals (specifically, opiates and neuropeptide Y). These chemicals can trigger mechanisms that are similar to the cravings you get from fat and sugar. In other words, when you get stressed, your brain feels the addictive call of fat and sugar and you’re pulled back to junk food.

We all have stressful situations that arise in our lives. Learning to deal with stress in a different way can help you overcome the addictive pull of junk food. This could include simple breathing techniques or a short guided meditation. Or something more physical like exercise or making art.

Where to Go From Here

One of my goals with this article is to reveal just how complex poor eating habits can be. Junk food is designed to keep you coming back for more. Telling people that they “need more willpower” or should “just stop eating crap” is short-sighted at best.

About the author:James Clear writes about using behavioral science to master your habits and improve your mental and physical health. If you enjoyed this article, join his free newsletter. Understanding the science behind junk food is an important first step, but I don’t want you to stop there. I wrote a free 46-page guide called Transform Your Habits, which explains strategies for winning the battle against junk food and improving your eating habits. You can download it here.