Peanuts, isolated on a white background
Tanawut Punketnakorn/iStock/GettyImages

Even though they're technically legumes rather than nuts, peanuts share many of the storage challenges associated with nuts. The high oil content of peanuts means that they can turn rancid quickly if they're not stored in the proper conditions.

Several factors can cause spoilage in peanuts. Heat increases the rate at which peanut oils turn rancid, while contact with moisture can lead to mold growth. Peanut contamination by mold can lead to the production of dangerous substances called aflatoxins. However, in the United States and most other countries, peanuts are closely inspected for aflatoxin contamination.

To prevent spoilage, keep peanuts in a cool, moisture-free environment. If you're planning to use them soon, a pantry or cupboard will do. For the longest storage time, a refrigerator is better. Refrigerated peanuts will last two to three times as long as unrefrigerated ones. Seal the peanuts in an airtight container like a sealable plastic freezer bag or tub. Peanuts come with their own little containers; for maximum shelf life, keep them in their shells. Unshelled peanuts stored in a pantry should last for one to two months, while peanuts without shells can go bad within a few weeks. Shells have no affect on how long you can store refrigerated peanuts.

For maximum length of storage, put your peanuts in a freezer, keeping them at or below 32 degrees Fahrenheit. In this state, peanuts will stay fresh for up to a year. If your peanuts are really raw -- if they've come out of the ground rather than from a store -- keeping them even colder will kill any possible insect pests and their eggs. Keep them below zero degrees, which is colder than most home freezers allow.