To scuba divers and amateur snorkelers alike, a fogging mask can be more than just annoying, it can be dangerous. Fortunately, in the scuba world, there is a consensus on how best to keep a mask from fogging up and thus prevent an obstructed view.
When a scuba or a snorkel mask is fresh from the manufacturer, it sometimes comes covered in a chemical coating that can cause fogging to occur. When dealing with a new mask, clean it out before using it, per the manufacturer's instructions. If none are included, scuba experts recommend a common, cheap, non-gel toothpaste as a reliable mask cleaner. To apply, clean your hands, put some toothpaste in the mask, and rub it around the glass and surrounding area with your finger. Rinse thoroughly. This should only be necessary with new masks, though if after trying the following steps your mask persists in fogging up, perhaps a more thorough toothpaste cleaning is in order.
Defogger is sold by the bottle and when applied before each dive should work perfectly to keep your mask fog-free. Again, make sure your hands are clean before applying a drop or two to the mask and working it around with your finger. Rinse any excess at the end.
Enzymes in human saliva will stick to the lens of your mask just like the defogging liquid mentioned above. Saliva is free and readily available. Spit into your mask and rub the saliva around the lens with your finger. Whether this solution will last as long as the commercial defogger is debatable, but that it works is fact. Rinse excess spit out of your mask and you are ready to go.