A cocoon is a casing spun of silk by many moths and caterpillars, and numerous other insect larvae as a protective covering for the pupa.
Cocoons may be tough or soft, opaque or translucent, solid or meshlike, of various colors, or composed of multiple layers, depending on the type of insect larva producing it. Many moth caterpillars shed the larval hairs and incorporate them into the cocoon. If these are urticating hairs then the cocoon is also irritating to the touch. Some larvae attach small twigs, fecal pellets or pieces of vegetation to the outside of their cocoon in an attempt to disguise it from predators. Others spin their cocoon in a concealed location—on the underside of a leaf, in a crevice, down near the base of a tree trunk, suspended from a twig or concealed in the leaf litter.
Insects that pupate in a cocoon must escape from it, and they do this either by the pupa cutting its way out, or by secreting enzymes, sometimes called cocoonase, that soften the cocoon. Some cocoons are constructed with built-in lines of weakness along which they will tear easily from inside, or with exit holes that only allow a one-way passage out; such features facilitate the escape of the adult insect after it emerges from the pupal skin.