Rescale an ingredient list
scale_ingredientsRescale recipe ingredient quantities to match any serving size or multiplier, handling units, approximate measures, and whole items so measurements stay practical.
Instructions
Rescale a list of English ingredient lines. This contacts no website and works on a list from anywhere, including one the user pasted in. Give either 'factor' directly, or 'from_servings' and 'to_servings' and the factor is computed. Grams, millilitres, ounces and pounds are multiplied and rounded to what a scale can show; a quantity that would fall below one is moved to a smaller unit first, so it never rounds away to nothing. Countable things land where a kitchen can follow, and what decides is the content rather than the container: a can, a packet, a sheet of gelatine or a spoon lands on a half, because half of one pours, weighs or cuts. An egg, a yolk, a white, a zest or a whole clove lands on a whole one, since there is no half of it to measure out, which is what stops an answer like '2.4 eggs'. A bottle, a jar, a block and a slice go one step further, to the quarter, as a whole food a knife shares out does. An approximate measure is scaled as a count, so a pinch taken from 6 servings to 25 is 4 pinches; the note gives the everyday equivalence, and the quantity stays in the unit the line used. That covers the gestures, such as a pinch, a dash, a glug or a handful, and anything named after what holds it, such as a capful or a spoonful. A line with no quantity at all comes back untouched and flagged. A bracketed equivalent, as in '450 g (1 pound)', is scaled with the amount it restates rather than left to contradict it, and so is one written after a slash, as in '500 g / 1.1 lb'. A line offering a choice, as in '2 tablespoons butter OR 30 g margarine', has both branches scaled, so whichever one the cook takes carries the same share. Prefer this over doing the arithmetic yourself.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| factor | No | Multiplier to apply. Use this or the from/to pair. | |
| ingredients | Yes | Ingredient lines, for example ['450 g (1 pound) spaghetti', '5 egg yolks', 'Salt']. | |
| to_servings | No | How many servings are wanted. | |
| from_servings | No | How many servings the list is written for. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| notes | Yes | ||
| factor | Yes | ||
| ingredients | Yes | ||
| scaled_count | Yes | Lines whose arithmetic came out exact. | |
| rounded_count | Yes | Lines whose value was moved to stay usable, not lines that could have been. | |
| unscaled_count | Yes | Lines carrying nothing that can be multiplied. |