If you've ever eaten a rancid nut, you know that eventually nuts do go bad. It takes a moment for your tastebuds to realize that a nut has turned, but then it's clear you have a problem. It's not harmful to digest a nut or two that have gone bad, but it's not pleasant. Once the unsaturated oils in an almond, cashew or pistachio have oxidized due to exposure to heat, air or light — or a combination of all three — they become inedible. At that point, they can be fodder for your compost pile or your kitchen trash.

The good news is that most nuts remain fresh — especially if their package is unopened — for a long time, and there are ways to help extend their life. To be clear, we're talking about shelled nuts that have been packaged, not ones still in the shell.

Almonds

Raw almonds in a bowl Shelled almonds can last two years past their best-by date if stored properly. (Photo: vanillaechoes/Shutterstock)

According to Eat by Date — a website that helps consumers navigate those pesky sell-by, best-by and use-by dates stamped on foods that are often arbitrary — says unopened almonds at room temperature can usually be good for nine to 12 months after their best-by date. The website points out that nuts do have a best-by date, which isn't meant to be an expiration date. After that date, the producer guesses the product will start to go downhill from its peak quality, but it's truly just a guess.

If the almonds are put into the refrigerator — which they should be unless you're going to eat them all within a week or two after opening the package, the nuts will last about a year. In the freezer, they can last up to two years.

Cashews

cashews Don't let expensive nuts like cashews go bad when there are easy ways to keep them fresh. (Photo: prasit jamkajornkiat/Shutterstock)

Cashews don't have as long as a shelf life as almonds do, but their ability to stay fresh when unopened is still respectable. You can count on an unopened package of cashews being good for an additional six to nine months after the best-by date has passed.

Cashews can be kept in the refrigerator for about a year and the freezer for about two years.

Pistachios

pistachios Pistachios should be eaten sooner rather than later. (Photo: FPWing/Shutterstock)

I buy shelled pistachios because they're so delicious and so small; it would be far too easy to eat many, many handfuls of shelled ones at a time. By purchasing them with the shells on, I have to work for that little kernel of goodness inside. However, it's possible to buy shelled pistachios. They don't have a very long shelf life, however. They last three months in the package past their best-by date, and once opened, they need to be eaten in a week or two. According to Eat by Date, they don't store well in either the refrigerator or freezer.

Pecans

pecans If you don't use opened pecans frequently, you can store them in the freezer. (Photo: Diana Tulian/Shutterstock)

The almonds, cashews and pistachios get eaten so quickly in my house that I never need to worry about storing them for long. Chopped pecans on the other hand are usually only used for my go-to 275-calorie salad or for holiday treats like Rugelach. I keep a small amount of chopped pecans in the refrigerator for when I make my salad and the rest go in the freezer.

Pecans can be kept in the pantry unopened for about six months past their best-by date. Once they're opened, unless you eat them in a week or two you can store them in the refrigerator for about a year. They can last a full two years if kept in the freezer.

Pine nuts

pine nuts If you buy pine nuts for pesto, make sure to store the unused ones in the refrigerator or freezer so they don't go rancid. (Photo: HandmadePictures/Shutterstock)

Pine nuts, used frequently to make pesto or to toss on salads, aren't quite as finicky as pistachios, but don't leave them sitting around too long. They'll last past their best-by date in their unopened packaging in the pantry for about one to two months. In the refrigerator they'll probably stay fresh for three or four months, and the freezer can extend their life for five or six months.

Walnuts

walnuts Walnuts are too super to let go to waste. (Photo: Adelart/Shutterstock)

There's so much goodness packed into a walnut, which is why they're considered a super nut. Don't let any of that goodness go to waste by letting the nuts get stale or rancid. Keep unopened packages of nuts in the pantry for six months past their best-by dates, in the refrigerator for up to a year and in the freezer for up to two years.

Robin Shreeves ( @rshreeves ) focuses on food from a family perspective from her home base in New Jersey.

How long do nuts last?
Most nuts are safe to eat past their best-by date, but eventually almonds, cashews and other nuts will go rancid.