At Chapman School in Nebraska, resourceful students hawk pizza and cookie dough to raise money for school supplies, field trips and an eighth-grade excursion to Washington. They peddle chocolate bars to help fund the yearbook.

But the sales won't be so sweet starting this fall. Campus bake sales—a mainstay of school fundraisers—are going on a diet. A federal law that aims to curb childhood obesity means that, in dozens of states, bake sales must adhere to nutrition requirements that could replace cupcakes and brownies with fruit cups and granola bars.

Jeff Ellsworth, principal of the kindergarten through eighth-grade school in Chapman, Neb., isn't quite sure how to break the news to the kids. "The chocolate bars are a big seller," said Mr. Ellsworth.

The restrictions that took effect in July stem from the 2010 Healthy, Hunger-Free Kids Act championed by first lady Michelle Obama and her "Let's Move!" campaign. The law overhauled nutrition standards affecting more than 30 million children. Among the changes: fatty french fries were out, while baked sweet potato fries were deemed to be fine.

The law also required the U.S. Department of Agriculture to set standards for all food and beverages sold during the school day, which includes vending machines, snack carts and daytime fundraisers. It allowed for "infrequent" fundraisers, and states were allowed to decide how many bake sales they would have that didn't meet nutrition standards.