depending on the machine you can put parts in the dishwasher....you'd have to look at the instruction manual for that. Don't use bleach or chemical cleaners as it may leave a residue and then you'll be breathing that in when you use the humidifier.
With mine...I discovered the only sure fire way to keep it clean was to rinse it out every morning and let it air dry or pat it dry with a towel. A dirty humidifier will make matters worse...so you want to make sure it's clean. It's a pain to do every morning...but it makes it stay clean.