Caterpillars mostly eat plant material, but some eat insects. The caterpillars of clothes moths chew through fabric. When they first hatch, many caterpillars eat their own eggshells. Some species of caterpillars are cannibals.
Many butterflies lay eggs on a specific type of plant. Some of these plants have toxins that are transferred to the caterpillar. This offers some protection from predators. For example, the monarch butterfly lays eggs on milkweed plants.
The larvae of some kinds of Eupethecia moth are carnivorous. The caterpillar holds its body in a way that mimics a twig; but when an insect brushes against it, it seizes the insect and consumes it.