A cocoon is a casing spun of silk by caterpillars and certain other insect larvae. Butterfly caterpillers do not spin cocoons. Some caterpillars 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, or down near the base of a treetrunk.
See also: Cocoon (movie), Cocoon (software)