You can spot clean backpacks for the most part, but when they're really filthy, a trip to the washing machine is in order. You can protect your backpack and washing machine with a pillowcase. Photo by Chris Winters.
Backpacks have all kinds of straps, buckles, zippers, and other things that could potentially get caught in the moving parts of a washing machine. Not to mention the straps themselves can get tangled around the spinning agitator if your washing machine has one. To avoid all that, just empty everything out of your backpack, open all the compartments, and place it inside a pillowcase. An old pillowcase you don't care about very much is best. Then tie the pillowcase shut and drop it in. Add a little detergent and wash it in warm water on the gentle cycle. This keeps your backpack and washing machine safe. Plus, if you didn't get everything out of your backpack (like change, pens, etc.), the pillowcase will keep those from going where they shouldn't. When it's done washing, hang it somewhere to air dry.