Guides

How does OnMacros build a day of meals within 5 g of each macro?

By OnMacros editorialUpdated November 3, 20265 min read
How does OnMacros build a day of meals within 5 g of each macro? title card

OnMacros builds a day by taking what you have already eaten as fixed, then sizing the foods still to come so protein, carbs and fat each end the day within 5 g of target. The grams come from arithmetic, not from a language model.

The day we will build

Take a target of 140 g protein, 220 g carbs and 55 g fat. Atwater's energy factors put protein and carbs at 4 kcal a gram and fat at 9 kcal a gram, so that target is 560 + 880 + 495 = 1,935 kcal. The FAO's chapter on energy conversion factors describes this general factor system: 17 kJ (4.0 kcal) per gram of protein, 37 kJ (9.0 kcal) per gram of fat and 17 kJ (4.0 kcal) per gram of carbohydrate.

Breakfast is already eaten: 70 g rolled oats, 200 g plain nonfat Greek yogurt and 120 g banana. Lunch is eaten too: 180 g chicken breast, 80 g uncooked white rice, 150 g broccoli and 10 g olive oil. The food values are the USDA FoodData Central figures used in the demo day on the OnMacros home page, and we ran the OnMacros planner on them to get every number below.

  • Breakfast: 30.9 g protein, 82.0 g carbs, 5.8 g fat
  • Lunch: 50.4 g protein, 73.9 g carbs, 15.9 g fat
  • Eaten so far: 81.3 g protein, 155.9 g carbs, 21.7 g fat
  • Left to reach target: 58.7 g protein, 64.1 g carbs, 33.3 g fat

That last line is the whole problem. Dinner has to bring about 59 g of protein, 64 g of carbs and 33 g of fat, all at the same time, from foods that each carry all three macros in their own fixed ratio.

Why this is not a guessing game

Pick salmon, sweet potato and spinach for dinner. Salmon brings protein and fat together. Sweet potato brings carbs. Spinach barely moves the numbers but fills the plate. If you add more salmon to fix protein, fat rises too. If you add sweet potato to fix carbs, you add a little protein with it. Every change touches more than one macro.

That is a set of linked equations. Three macros give three equations, and the grams of each food are the unknowns. A solver can find the grams that satisfy all three together and then check the answer against the real portion limits, such as a cap on how much of one food makes sense on a plate.

The planner works in a fixed order:

  1. Foods you already ate are pinned at their logged grams and never move.
  2. The foods you chose for the remaining meal become adjustable.
  3. The solver sizes the adjustable foods against what is left of each macro.
  4. The result is checked against the 5 g window for protein, carbs and fat.

What the planner returned

For the dinner above, the planner sized 240 g of Atlantic salmon, 291.7 g of sweet potato and 150 g of spinach. That dinner adds 58.1 g protein, 63.8 g carbs and 33.1 g fat, which is 784.6 kcal using the food database energy values.

  • Protein: target 140 g, day total 139.4 g, gap 0.6 g
  • Carbs: target 220 g, day total 219.7 g, gap 0.3 g
  • Fat: target 55 g, day total 54.8 g, gap 0.2 g

Every macro lands inside 1 g, far tighter than the 5 g window. Before dinner the day had 797.5 kcal left on the 1,935 kcal target. After the planned dinner, 12.9 kcal remain, which is why the home page shows the header dropping from 798 to 13 kcal left.

Why 5 g is the window

Five grams is a deliberate choice. Food labels round, scales have limits, and nobody weighs a banana to the gram. A tolerance much tighter than 5 g would mean a plan that fails every time real life adds a bite of something. A tolerance much looser would let a day drift on one macro and still count as a hit. Five grams keeps the result honest while leaving room for the way people actually eat. The next article in this series shows what 5 g is worth in calories.

Where the AI fits

The conversation is where you say what you want: which foods you like tonight, what is in the fridge, what you ate for lunch. The AI turns that into a list of foods and a request to size them. It does not invent portions. Once foods are on the table, the solver does the work, and a later change such as swapping the salmon for chicken only touches the named food.

Food values come from real databases. If you want to know exactly where, the FoodData Central documentation lists its data types and how often each is updated.

What can go wrong, and what you see

Some days cannot be hit with the foods on the table. If you ask for a high protein dinner and name only rice and bananas, no portion of those foods can reach the protein you need. A planner that hides that is worse than none. When a macro stays outside the window, OnMacros reports the reason, for example that the chosen foods have no good source of that macro or that a portion limit stopped the solver, so you can add a food rather than trust a number that does not add up.

The short version

  • Your target is three numbers, and the sum in kcal follows from them.
  • What you ate is fixed.
  • What is left is solved, not guessed.
  • The answer is checked against a 5 g window before you see it.

That loop, repeated at the end of each day, is how a plan stays on target without meal prep.

Questions

Does the AI decide the gram amounts?

No. The AI picks which foods to put on the table. The gram amounts come from a solver that runs ordinary arithmetic on the food values, so the same inputs always give the same plan.

What if the foods I pick cannot reach the target?

The planner says so. When a macro stays outside the 5 g window it reports why, for example that no chosen food supplies enough of it, instead of handing you numbers that look fine and are not.

Can I lock a portion I want to keep?

Yes. A portion you pin stays exactly as you set it, and the planner sizes the other foods around it.

Sources