Pillows start yellowing due to sweat and oil buildup, and while your pillowcase and regular maintenance can protect your pillow, it’s still common to see discoloration over time.
A simple way to whiten and wash your pillow is to combine 1 cup of laundry detergent, 1 cup of powdered dishwasher detergent, 1 cup of cup bleach (if your pillow is bleach-safe), and half a cup of borax. Let the detergent dissolve before adding it to your washing machine or hand-washing your pillow.
You might also try using a baking soda and vinegar mixture for a natural cleaning solution, though it might not work as well.