As beauty tools go, your hairbrush gets really gross, really fast. Humans shed an average of 50–100 hairs per day, many of which get stuck in your brush along with a build-up of hair care products, dead skin cells, and dust (a ripe environment for bacterial and fungal growth). If you don't keep your brush clean, this grime can end up back in your hair, which not only makes your hair dirty and increases the risk of tangling and damage but can also exacerbate scalp issues like dandruff or seborrheic dermatitis.
If your brush looks like it needs to be cleaned, it definitely does. You should remove the hair from your brush as it accumulates (every day or so) and do a thorough clean once a week if you use any styling products, such as gel or hairspray (or every two to three weeks if you don't).
First things first: Pull the hair out of your brush's bristles. Start by using your fingers, but if there are clumps that get stuck you can dig them out with a pointy object such as a chopstick, toothpick, or sharp comb end or cut with scissors. Again, do this regularly to prevent build-up.
Next, you need to wash the brush:
Fill a stopped sink, bin, or bowl with warm, soapy water. You can use dish soap or gentle shampoo to wash synthetic (plastic and rubber) brushes, but if your brush is natural (made of wood or boar bristles), go with a sulfate-free shampoo. You can also add one to two teaspoons of baking soda.
Soak your synthetic brush, including the bristles, for 10 minutes. For natural brushes and brushes with padding, dip the bristles into the water but do not submerge. This softens all of the gross bits to make them easier to remove.
Remove the brush, shake it off, and re-soak if a lot of build-up remains.
Use your fingers to pull any grime off of individual bristles.
Use a clean, spare toothbrush dipped in the soapy water to scrub around the base of and up the bristles. Scrub anywhere else that there's build-up.
Rinse your brush in cool running water, squeeze or shake out any excess, and place it face-down to dry.
Regularly cleaning your hairbrush will lengthen its life, but there will come a time when it's best to replace it, such as when there are broken, bent, or missing bristles as well as cracks. Inspect your brush regularly.