Glass jars containing liquids should be stored upright in the pantry to prevent leaks and spills. Jars containing dry goods can be stored either upright or sideways, depending on space and preference.
The primary reason to store glass jars upright, especially those containing liquids like sauces, jams, or pickles, is to maintain an airtight seal. When a jar is stored on its side, the liquid contents can come into contact with the lid, potentially weakening the seal over time. This can lead to leaks, spoilage, and a messy pantry. Furthermore, if the lid isn't perfectly sealed, storing the jar sideways will definitely cause leakage. For dry goods like spices, grains, or beans, the orientation matters less, as there's no risk of leakage. You can store these jars sideways if it helps optimize space in your pantry. However, keeping them upright can make it easier to identify the contents at a glance.
Before storing any jar, especially those you've canned yourself, always check the seal by pressing down on the center of the lid. If it flexes or pops, the seal isn't airtight, and the contents should be refrigerated and used promptly or reprocessed.