Short answer
Caterpillars don’t sleep in the way mammals do. They have no eyelids, and larval sleep is poorly studied, so scientists are not sure how close their resting is to sleep. What they do is alternate feeding with rest. They eat, stop and keep still while they digest, then return to feed.
How long they rest
Rests between meals can last from ten or fifteen minutes to a few hours. Younger caterpillars often take longer rests than older ones. In cold weather, some caterpillars enter a torpor, a state of very slow metabolism, that can look like hibernation. Before resting, a caterpillar often moves to a sheltered spot under a leaf or in a silk shelter. When it wakes, it may feed on the leaf it rested under.
Resting positions and defence
Many resting positions are defensive. Loopers grip with their rear prolegs and hold rigid, like a twig. Hawk-moth caterpillars often hold a sphinx pose, with the front of the body raised. Other species curl up and tuck the head in. A still caterpillar may be resting, but it may also be avoiding a predator.
Night feeders
Some caterpillars feed at night and hide by day. Cutworms and the large yellow underwing caterpillar, for example, shelter in soil or leaf litter during the day and come out to feed after dark. A caterpillar that is inactive by day may still be feeding at night. Look for fresh frass (droppings) and nibbled leaves to check.
Stillness before moulting and pupation
Before each moult, a caterpillar stops feeding and stays still for several hours to a day or two. This stillness is part of the moult, not sleep, and disturbing it can kill the caterpillar. Pre-pupal larvae also stop feeding, often wander, empty their gut and may change colour before they pupate. For the triggers behind that change, see how do caterpillars know when to cocoon?. For how often and why caterpillars moult, see how many times does a caterpillar shed its skin?.
Diapause is not sleep
Some caterpillars spend the winter in diapause, a dormancy in which development pauses for weeks or months. Diapause is not a night’s sleep, and it isn’t the same as hibernation in mammals. Many UK species overwinter as larvae. The garden tiger and fox moth are examples, and both bask in the spring sun to raise their body temperature.
What this means if you are rearing one
If you are keeping a caterpillar at home, leave a still larva alone. Don’t move a resting pre-moult caterpillar, and don’t assume it is ill. Check for fresh droppings to confirm it is still feeding. For the full set-up, see how to raise caterpillars at home. For a garden species that overwinters as a larva, see is it safe to pick up a woolly bear caterpillar?.