Cooking with onions is very common, as the onion has a lot of natural sugar that lends flavor to foods whether in raw form or cooked. Onions generally store quite well, whether you refrigerate them or store them in a dry closet. When you have an onion that has partially gone bad, it may not be necessary to throw it away.
Is the Whole Onion Bad?
Onions are a vegetable, and vegetables are made of separated cells, which means that if one group of cells turns bad, the entire vegetable is not affected. By removing the affected cells, you can keep the healthy part of the onion. This is different than meat or dairy, where bacteria will infiltrate the entire portion of the sample and not just a section of it.
When organic material decays, it putrefies. This process is the breakdown of the organic material by the bacteria consuming it, and the resulting waste from that digestion. Enzymes are released during the digestive process, and this converts the solids into liquids, while releasing gasses that smell offensive. In essence, the mushy part is the result of being "digested" by the invading bacteria.
Which Part Is Good?
Identifying the good part of the onion is critical before trying to salvage it. A healthy onion has firm skin and "meat," and will be the color of the original onion -- i.e., red, white or yellow. The outer part of the onion is covered with a thin, dry skin that flakes and tears easily. An onion is not wet unless it is cut, and the juice running from a fresh cut onion will be clear, smell strong but not unpleasant, and definitely will not smell rotten.
Salvage the Good
Once you have determined where the good part of the onion is, it is time for surgery. Get out a clean, sharp knife and cut away all the mushy part of the onion, and a good portion around it to make sure all contaminated material has been removed. There should be no question of freshness in the onion you save.