Caterpillars make their cocoons from strands of silk that they produce from glands near their mouths. They use their mouthparts to weave the silk, which is sticky at first, into a cocoon.
Some caterpillars make very loose, open cocoons, while others build very strong, tightly-woven cocoons.