Caterpillars do sleep. During the daytime, they sleep on the underside of leaves. When they wake up, caterpillars eat the leaves they were sleeping on. They continue this process until they begin the metamorphosis period.
Caterpillars also sleep after they begin metamorphosis from caterpillar into butterfly. Once they are hanging by thread they have produced, the caterpillar rests until the pupa stage begins. Once this has occurred, they sleep until the pupa stage develops into the chrysalis. Scientists believe that during the subsequent 10 to 14 days, the caterpillar sleeps in its chrysalis until it emerges as an adult butterfly.