How the recipe nutrition calculator works
A recipe nutrition calculator multiplies each ingredient’s nutrition per 100 g by the grams used, adds the rows, and divides by the number of servings. The hard part is the grams, and the recipe nutrition calculator spends most of its work there: a recipe says “3/4 cup brown sugar, packed”, and the data says a packed cup weighs 220 g. The calculator reads the amount and unit, looks for the food in USDA FoodData Central’s SR Legacy release, then uses that food’s own household measure. When the line names a preparation such as packed, sliced or chopped, it picks the measure that matches.
For a nutrition calculator for recipes, the measure is the whole problem, so the food search scores whole words, singular and plural, and prefers the plain food over a processed form unless the line asks for one. “Apples” finds raw apples before dried apples, “butter” finds salted butter at the top, and a line with no unit can use a measure named after the food, such as one avocado. The first result is selected, and the page shows the next four so a cook can correct a match in one click. A search box reaches the rest of the 7,793 foods.
The recipe nutrition calculator keeps each row’s measure and grams. For a recipe calorie calculator, that means a corrected match or measure flows straight into the totals. Change a match and the row starts again from the new food’s data; change the measure and the grams follow the measure. Type grams yourself and the row uses your number, which is what a kitchen scale is for. The total ingredient weight, shown in the Per serving box, and the grams per serving update as you go. The data is SR Legacy 2018-04 from USDA FoodData Central, public domain, and the page fetches only the index and the shards it needs.
2 1/4 cups all-purpose flour
- Wheat flour, white, all-purpose, enriched, bleached
- Wheat flour, white, all-purpose, enriched, unbleached
- Wheat flour, white, all-purpose, unenriched
- Wheat flour, white, all-purpose, enriched, calcium-fortified
- Wheat flour, white, all-purpose, self-rising, enriched
- Cocoa, dry powder, unsweetened
- Cocoa, dry powder, unsweetened, processed with alkali
- Cocoa, dry powder, hi-fat or breakfast, processed with alkali
- Spices, curry powder
- Spices, chili powder
Search any of the 7,793 foods