Look carefully at the material, stitches, and the brim. If your hat is made with good quality materials, is relatively new, and has solid stitching you should be able to wash it without trouble. Look for signs that the hat is inexpensive or poorly constructed. If the cap has loose stitching or a cardboard brim it might fall apart if you wash it. If the hat was inexpensive it might make more sense to replace it than to attempt to wash it. [1] X Research source
Determine the kind of fabric. If your hat is made from cotton, polyester, or twill and is well made you should be able to wash it. If the cap is made from wool you should only hand wash it using a special detergent designed for wool, like Woolite. [3] X Research source
Use a very small amount of mild detergent on a rag or washcloth and rub it on a small area on the hat. Chose an area on the inside part of the hat that is hidden when wearing. Rinse it gently with cool water. If the color stays the same you can wash the rest of the hat.