Steam From Melting Butter Puffs Your Cookie and Leaves It Flaky
When butter melts, its hidden water becomes steam, shoves the dough outward, then vanishes and leaves air behind.

TED-Ed · The chemistry of cookies - Stephanie WarrenSlide a tray of cookie dough into a hot oven and the first real action comes from the butter.
Butter looks solid, but it is a forced blend of fat and water that would rather separate, held together with a little dairy solids. At 92 degrees Fahrenheit the butter melts, the dough starts to spread, and the trapped water breaks free.
As the cookie gets hotter, that water turns to steam and expands. It presses outward from within the soft dough, seeking a way out through the cookie walls, like the chest-bursting creature in the film Alien.
The push is temporary. At 212 degrees water boils away, and the cookie dries and firms much as wet earth hardens on a hot day. The surface then cracks.
That is also what makes the texture. When the bubbling steam finally evaporates, it leaves behind small, airy pockets that make the finished cookie light and flaky.
Questions people ask
Does it matter if my butter is cold or melted when I mix the dough?
It can. As general baking knowledge, cold butter melts later in the oven, so the steam arrives later. That timing means the dough spreads a little less before it sets.
Does the same steam trick work with margarine?
Yes. Margarine is also a water in oil emulsion, so it also holds water that can turn to steam in the oven. Because the fats and solids differ, the taste and spread are not quite the same.
Is steam the only thing making cookies puff up?
Steam is one of two lifters. Baking soda, also called sodium bicarbonate, reacts with acids in the dough to make carbon dioxide gas. Those bubbles add their own airy pockets alongside the ones left by steam.