There are many different species of caterpillars, in order to get rid of them; you first need to know what type of caterpillar you are dealing with. If you are dealing with an indoor caterpillar, you must locate their food source, clean your pantry and keep food sealed. Do not leave any food out and vacuum crumbs. Timing is key when trying to prevent caterpillars in your garden. Be sure to fertilize your garden and take good care of it.