"Certain highly organized groups of cells known as imaginal discs survive the digestive process. Before hatching, when a caterpillar is still developing inside its egg, it grows an imaginal disc for each of the adult body parts it will need as a mature butterfly or moth—discs for its eyes, for its wings, its legs and so on. In some species, these imaginal discs remain dormant throughout the caterpillar's life; in other species, the discs begin to take the shape of adult body parts even before the caterpillar forms a chrysalis or cocoon. Some caterpillars walk around with tiny rudimentary wings tucked inside their bodies, though you would never know it by looking at them."
There's a great radiolab show where they address this:
By the way, "cocoon" is probably not the word you're looking for.
[This is a pupa](https://upload.wikimedia.org/wikipedia/commons/1/1a/Nymphalidae_-_Danaus_plexippus_Chrysalis.JPG) (also known as a chrysalis). It's the stage a holometabolous insect passes through before adulthood. So it's not a shell or container or anything; it *is* the insect. That green stuff is the skin of the animal. For comparison, [here's a ladybug pupa](https://upload.wikimedia.org/wikipedia/commons/f/fd/Multicolored_Asian_Lady_Beetle_Pupa_%2814401873284%29.jpg), and [these are bee pupae](https://upload.wikimedia.org/wikipedia/commons/6/62/Drohnenpuppen_79d.jpg).
[These are cocoons](https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Cocoon_-_Bombyx_mori_-_Kolkata_2013-06-04_8545.JPG/1280px-Cocoon_-_Bombyx_mori_-_Kolkata_2013-06-04_8545.JPG). As you can see, they're made of silk, which is produced glands on the caterpillar's face. Some insects (but rarely butterflies) make cocoons before pupating. If you cut open a cocoon, you'll usually find a pupa inside it.
This has been a very informational thread—either of things I looked up and promptly forgot or new things entirely.
Another question to add to the thread: if during the liquified state of pupation, one were to inject a needle and remove some of the “thing”, come adulthood (if it survived to that stage), we’d see a butterfly with missing parts rather than a smaller adult, correct? (That’s my understanding of the imaginal discs /u/SelfRefMeta mentions)
I have a question related to this, I hope it's okay for me to ask.
We had over one hundred chrysalis (chrysali?, chrysalises?) on our house this year, and most of them left what looks like a blood stain that came out the bottom. Is that just normal or did something go wrong and the butterflies didn't make it? We saw several that came out deformed or fell out of the chrysalis onto the ground and never flew away.
Also, if anyone knows how to remove the stain the butterflies left, I'd appreciate it. Our house looks like a murder scene.