Yes! Dehumidifiers, especially in musty or humid environments, are a great way of removing moisture from the air which can increase overall air quality. Leaving them on throughout the night is typically safe, as many have automatic shutoff functions when the water collection tanks are full, and shutoff functions if the device overheats.