Yes, sunlight kills molds and mildew and gets ride of nasty smell too. No, airing in the sun will not totally disinfect mattresses and pillows.

When I was a young girl, I’d sleep over at my grandparents’ house during weekends. I’d stay at my aunt’s room and, every morning upon waking up, she’d take the pillows and pile them on the window ledge. “So they wouldn’t stink,” she said.
Fast forward to so many decades later when I was a mom with toddlers who still weren’t fully potty trained. I can’t remember anymore the number of times we lugged mattresses and pillows out in the sun to get the stink off. I never really thought much about the why; I only knew that a few hours under the sun and the stink was neutralized.
Did airing them in the sun disinfect them too? I think about all that now as I look at the damp cushions, pillows, mattresses and drapes around the house. It’s typhoon season and we just got hit by the world’s strongest typhoon this year. The dampness in the house is not that serious a problem, I know, considering the deaths and damage Super Typhoon Mangkhut brought to those in its direct path.
Still, I have to think about the dampness. Mildew and molds grow and multiply on damp fabric and molds can trigger allergies. I’m wondering how much stuff can be lugged out into the garden when the sun comes out. And I’m thinking that it might not be soon enough because rain is forecast in the coming days. Should I wait for the sun? Is it really the best solution?
Yes, sunlight kills molds and mildew and gets ride of nasty smell too
Oh, I don’t doubt that sunlight kills molds and mildew. The UV rays do a good job. And it isn’t just molds on fabric that sunlight can kill. Place damp books and furniture under the hot sun for a couple of hours and the tell-tale spots should be gone. Sunlight will also remove any musty smell.
But what if it’s still cloudy and drizzly and it’s likely to stay that way for days? I browsed the web and found substitutes that reputedly work just as well as, if not better than, sunlight. All require a simple spray bottle and an assortment of common household items.
1. Vinegar: Pure or diluted.
2. Vodka
3. Denatured alcohol
4. Hydrogen peroxide
5. Baking soda
All five will get rid of musty odor too.
No, airing in the sun will not totally disinfect mattresses and pillows
Even if not dealing with molds and mildew, many people do bring out their mattresses and pillows to air them in the sun. Mostly, to deodorize them and to get rid of dust mites. Because, yes, after a while they get stinky.

Think of the perspiration (and occasional drool) that gets on them. Think of the natural oil of the human skin that gets in contact with them. And, if you have pets that you bring into the bedroom, the stink is likely even worse. Airing in the sun works.
But disinfecting? I think not — at least, not totally. UV rays might get rid of what’s on the surface but what are buried deep inside are unlikely to be eradicated. In fact, with the world being what it is today when pollution has gone up tremendously, leaving mattresses and pillows out in the open for too long will likely get them more dirty than clean.
The best solution, really, is to change sheets and pillowcases often AND replace mattresses and pillows regularly. And that applies to cushions and coverings of couches too.
Sunlight streaming from windows equals an ounce of prevention

Meanwhile, between changing the sheets and replacing mattresses, pillowcases and cushions, there is a way to prevent them from getting molds, deodorize them and let them get some sun too without bringing everything out into the garden.
It’s simple. On sunny days, position your beds and couches by the window where a good amount of sunlight passes through. Keep the windows open to allow the air to circulate — and this is especially important if, for most part of the day or night, the air-conditioner is on and all doors and windows are closed.