You may be surprised to discover what actually goes on during the transformation from caterpillar to butterfly. Of course we can't actually see inside of a chrysalis, but in the name of science people have on occasion taken apart a cocoon to see what's all the buzz during those mysterious days while a great change is occurring. And what they found is quite surprising.
A caterpillar inside a chrysalis actually digests its own body from the inside out, utilizing the same juices it used to digest food as a larva in order to break down its own body! The fluid breaks down the old caterpillar body into cells called imaginal cells, which are undifferentiated cells that can develop into any type of cell. These imaginal cells form the new body that becomes a butterfly. Can you imagine decomposing your body and creating a new one a matter of just a few days?
This transformation is called holometabolism and usually takes about two weeks. However some species will stay inside their cocoon for month in order to avoid winter. When they are finally ready to emerge after their unique body switch, they will cut their way out of the cocoon from the inside or secrete fluids that soften the cocoon and make it easier to escape.