Whether you enjoy a handful of almonds as an afternoon snack, sprinkle walnuts over your oatmeal, or keep pecans on hand for your favorite baking recipes, nuts are worth keeping in your kitchen. But if you've ever opened a package only to find that your once-crunchy snack tastes bitter or smells a little off, you might be wondering how to keep nuts fresh for longer.

Their shelf life depends on several factors, including the type of nut, how it's packaged and where it's stored. To help you get the most out of every bag, here's what an expert wants you to know about keeping nuts fresh and recognizing when they've gone bad.

Where should you store nuts?

Nuts in jars or cans can last about 12 months unopened in the pantry. After opening, however, their shelf life decreases to approximately two to nine months in the pantry, four to six months in the refrigerator and six to 12 months in the freezer.

The reason comes down to their fat content. As Dr. Darin Detwiler, a food safety expert, author, and professor emeritus of food policy, explains: "Nuts are high in oil, especially unsaturated fats." While these oils offer nutritional benefits, they're also vulnerable to oxidation, a process that causes fats to break down and become rancid.

“Heat, light, air, and moisture speed rancidity,” says Dr. Detwiler. “Rancid nuts may not always make people acutely ill, but they taste bad, degrade nutrition, and signal poor storage.”

Therefore, Dr. Detwiler says the best place to store nuts for freshness is the refrigerator or freezer, rather than the pantry—especially after opening.

Which nuts go bad the fastest?

High-fat nuts—like walnuts, pine nuts, pecans, macadamia nuts, Brazil nuts, pistachios, and almonds—are particularly prone to going rancid compared to others.

How you prepare your nuts also matters. "Chopped, sliced, ground, or roasted nuts spoil faster than whole raw nuts because more surface area is exposed to oxygen," Dr. Detwiler explains.

If you regularly buy nuts in bulk or prefer to keep them on hand for baking and snacking, freezing them in an airtight container can be a practical way to extend their freshness.

How to tell if nuts have gone bad

Before adding nuts to your oatmeal, salad or favorite baked goods, check for signs of spoilage. According to Dr. Detwiler, warning signs include a bitter flavor, sour smell, paint-like or chemical odor, stale cardboard smell, darkening, shriveling, mold, stickiness, or insect activity.

If your nuts smell rancid or show signs of mold, discard them rather than trying to salvage them. And while keeping a small batch of nuts that you’re planning on eating soon in the pantry should be OK, moving them to the refrigerator or freezer extends their life by preserving their flavor and quality.