Some 4,000 years ago, a culinary genius in ancient Mesopotamia had the brilliant idea to soak cucumbers in an acidic and salty brine to make them last longer.

Ever since, generations after generations of cooks have been pickling cucumbers. Those fortunate enough to live with them, on the other hand, have been coming up with every excuse possible to munch on the delicious dills.

For four millennia, you’d think we’d have cleared up the ground rules of pickling by now. Yet ask anyone whether pickles go bad—and how long it takes till they get there—and you’d end up with about as many different answers as the number of people you asked.

What a… pickle.

An avid store-bought pickle eater and pickler myself, in this post, I will give you my honest take on the topic.

Unopened pickles can be stored in your pantry or cabinets, and will usually last for 2 years. Once opened, pickles should be stored in the fridge, where they will stay good for 3 months.

Of course, there’s more to it than meets the eye, which is precisely what we’ll be talking about in the rest of this article. If you want to know how to keep your dills fresh for as long as possible, keep on reading.

How to Store Unopened Jarred Pickles

An unopened jar of pickles is considered shelf-stable, which means that it doesn’t have to be refrigerated and can be stored in a cool and dry place, such as your root cellar, pantry, or inside a cabinet, instead.

Keep jarred pickles away from sunny spots in your kitchen, such as a windowsill, as well as from sources of heat like your range or the back of your fridge (fridges work by expelling heat from the cooling box to the back of the appliance).

Pickles, as long as they’ve been properly sealed and the lid on the jar shows no sign of bulging, will stay safe to eat for at least 2 years, in some cases well past the “best by” date printed on the top of the lid, the jar’s bottom, or somewhere on the label.

How to Store an Opened Jar of Pickles

Once you’ve opened a store-bought jar of pickles, reseal it and keep it in the fridge. In case you can’t reseal the original packaging, transfer the dills, along with enough of the brine, to a jar with an airtight lid or to a food storage container.

Opened pickles, pasteurized or unpasteurized, are safe to eat and keep their best qualities for up to 3 months in your fridge, provided that the jar has been sealed and the pickles are submerged in the brine.

The same applies to homemade pickles, with a few caveats:

Make sure your brine consists of at least 1 part vinegar to 1 part water. Some go as far as to suggest using a brine of 2/3 parts vinegar and 1/3 parts water. A non-iodized salt, such as pickling, kosher, or sea salt is better as iodized salt can make your brine cloudy.

To preserve the pickles for as long as possible, don’t pluck them out from the jar with your hands (by doing so, you can easily transfer bacteria from your fingers to the brine) and use utility thongs or a fork.

Can Pickles Be Left Out?

Unopened pickles are shelf-stable; opened pickles are not. So, when it comes to storage and safety, treat the latter just like you’d treat any other perishable food item, and don’t let it sit on the counter for too long.

Don’t leave pickles out at room temperature for longer than 2 hours. Bacteria thrive at temperatures from 40°F to 140°F, a range that the U.S. Department of Agriculture refers to as the “danger zone.”

This applies to both store-bought and homemade pickles, no matter if they’ve been pasteurized or not.

Do Pickles Go Bad?

Sealed tightly and stored properly, a jar of pickles can last for a really long time. As with any other food item, though, it will eventually go bad.

The tell-tale signs that jarred pickles have gone bad are a bulging lid, off odor, and overly soft, noticeably mushy texture. If you notice any of these signs, throw the pickles in the trash can or compost pile so that nobody else at home makes the mistake of eating them.

Food-borne illness is nothing to be played around with and, when it comes to food safety, especially with pickled foods, the general rule of thumb to abide by is “better safe than sorry.”

Can You Eat Pickles Past Their Best-By Date?

When food items are past their best-by or sell-by date, the answer to whether you should eat them or not is almost always “it depends.”

Don’t get me wrong: it’s not uncommon for pickled foods to stay safe to eat for years past their best-by date. On the other hand, eating expired food items can be a gamble—and it’s probably not worth the risk, even if you have the appetite for it.

Pickling pros say that fuzzy mold growing on the brine’s surface in a jar of pickles isn’t always an issue. In theory, you can safely scoop it off, wipe the edges of the jar with a cloth or paper towel, and munch on the dills inside. In practice, I’d discard them on any day.