Summer is the season of state fairs, and with state fairs comes fair food, the inevitable accompaniment to the Ferris wheel, the Scrambler, the bumper cars, and the carousel. I’m talking corn dogs, fried dough, funnel cake, taffy apples, soft pretzels, onion rings, snow cones, and pink-and-blue bowling-ball-sized puffs of cotton candy.

While these are hardly the stuff of the ideal diet, cotton candy, surprisingly, is the least caloric of the lot, a mere 105 calories for a standard one-ounce serving. The reason for this is that cotton candy is mostly non-caloric air. The rest, however, is pure sugar.

Perversely enough, cotton candy was invented by dentist­ William Morrison, with the help of confectioner John C. Wharton. Together, in 1897, the pair designed and patented what they called an electric candy machine: a metal bowl containing a central spinning head filled with sugar crystals and perforated with minuscule holes.

Their creation worked much like modern cotton-candy machines today. At the top of the head, a heater melts the sugar, reducing it to syrup. At the same time, centrifugal force generated by the spinning head­—which whips around at a dizzying 3,400 revolutions per minute— forces the liquid sugar through the tiny holes. As the syrup sprays through the holes, it solidifies almost instantly into long skinny strands, just 50 microns (two-thousandths of an inch) in diameter.

The syrup cools so rapidly that the sugar never gets a chance to re-crystallize, instead forming a disorganized, amorphous solid. What you’re eating, when you chow down on a giant poof of cotton candy, is the sugar version of glass.

View Images Cotton candy is a must at the fair. Photograph by Helene Rogers, Alamy

Morrison and Wharton’s electric candy machine first came to the attention of the public at the Louisiana Purchase Exposition of 1904, popularly known as the St. Louis World’s Fair—a seven-month-long extravaganza, featuring among the exhibits a re-enactment of the Boer War, the world’s largest pipe organ, a 265-foot “Observation Wheel,” and an elephant water slide. An estimated 20 million people attended the fair, to whom Morrison and Wharton sold 68,655 helpings of cotton candy. They packaged it in wooden boxes and marketed it as “fairy floss.”

The term “cotton candy” was adopted in the 1920s under the auspices of Josef Lascaux, another candy-purveying dentist. Lascaux, who sold cotton candy to his patients, attempted but failed to improve on Morrison and Wharton’s original candy-making machine, which had a distressing tendency to rattle, shake, and fall apart. This problem was finally solved in 1949 by the addition of a spring-loaded base, an innovation so effective that its instigator, Gold Medal Products of Cincinnati, is still the world’s main producer of cotton candy machines. In 1951, Gold Medal sealed the deal but inventing a machine that could roll a flat piece of paper into a perfectly tapered cotton-candy cone.

Cotton candy isn’t a modern invention. According to Tim Richardson’s Sweets: A History of Candy, it dates back at least to the 15th Century, when creative Italian cooks fashioned fantastic sculptures from spun sugar, first melting the sugar, then drawing it out with a fork and draping the thin strands over a wooden broom handle.

In the 16th Century, Henri III of France, on a state visit to Venice, was treated to an all-sugar banquet, complete with spun-sugar cutlery and tablecloth; and in the early 19th Century, French celebrity chef Marie-Antoine Carême—who made Napoleon’s wedding cake—was famed for his spun-sugar windmills, fountains, gondolas, temples, and palaces. Even the less exalted cook could try her hand at spun sugar: Elizabeth Raffald’s The Experienced English Housekeeper (1769) includes recipes for gold and silver webs for covering sweetmeats, made by drawing sugar syrup up with a knife tip and whipping it “as quick as possible backwards and forwards” across a mold made from an inverted buttered bowl.

Still, spun sugar was tricky and labor-intensive, and it remained—until the advent of the cotton-candy machine— a snack or dessert of the leisured rich.