Macro Calculator Widget
Add a macronutrient calculator to your website. Visitors type in their daily calories, or estimate them from their details, choose a balanced, lower-carb, higher-protein or custom split and see grams of protein, carbohydrate and fat per day.
Live preview
Exactly what your visitors will seeUnder the widget on your page: Powered by A2Z Tools
Embed code
<iframe src="https://a2z.tools/embed/w/macro-calculator" title="Macro Calculator by A2Z Tools" width="100%" height="730" style="border:0;width:100%" loading="lazy" allow="clipboard-write"></iframe>
A plain iframe. Works everywhere, including site builders that strip scripts. Adjust height if your content needs more room.
<div data-a2z-widget="macro-calculator" data-height="730"></div> <script async src="https://a2z.tools/embed.js"></script>
Adds a small script (what it does) that sizes the widget to fit its content, loads it lazily and keeps it isolated from your page's CSS.
Works with
How it works
Calories can be entered directly, or estimated with the Mifflin-St Jeor equation times an activity factor and a goal adjustment - the same method as the calorie calculator widget, with the same warning below 1,200 or 1,500 kcal. The calories are then split by percentage and converted to grams with the Atwater general factors that FAO documents: 4 kcal per gram for protein and carbohydrate and 9 kcal per gram for fat. Three presets cover common approaches, and a custom option accepts any split that adds up to exactly 100%. Every result is checked against the US National Academies' Acceptable Macronutrient Distribution Ranges for adults, and the note names any macro that falls outside them - including the presets, two of which do. When body weight is known the widget also shows protein per kg (or per lb).
Calculation method
- Protein (g) = kcal x protein% / 100 / 4; carbohydrate (g) = kcal x carbs% / 100 / 4; fat (g) = kcal x fat% / 100 / 9
- Presets (protein / carbs / fat): balanced 30/40/30, lower carb 35/25/40, higher protein 40/35/25
- AMDR check (adults): protein 10-35%, carbohydrate 45-65%, fat 20-35% of energy
- Estimated calories = Mifflin-St Jeor BMR x activity factor + goal adjustment (-500 to +500 kcal); grams and kcal rounded to whole numbers
Worked examples
2,000 kcal, balanced preset
Inputs: 2,000 kcal known, 30 / 40 / 30
Result: Protein 150 g, carbohydrate 200 g, fat 67 g; note: carbohydrate 40% is outside the AMDR
600 / 4 = 150, 800 / 4 = 200, 600 / 9 = 66.7.
1,800 kcal, custom split inside the AMDR
Inputs: 1,800 kcal, custom 20 / 50 / 30
Result: Protein 90 g, carbohydrate 225 g, fat 60 g; within the AMDR
360 / 4, 900 / 4 and 540 / 9.
An estimate for general information only - not medical advice. Talk to a doctor or registered dietitian about your health.
Limitations
- The AMDR is a population reference for healthy adults; it does not set targets for athletes, kidney disease, diabetes or pregnancy.
- Fibre, alcohol (7 kcal/g) and food-specific Atwater factors are not modelled.
- The calorie estimate inherits the limits of the BMR equation and activity multipliers.
Where publishers use it
- Online coaches and meal-plan services giving clients gram targets
- Recipe and meal-prep blogs that list macros per serving
- Bodybuilding and strength-sport sites explaining protein targets
- Dietetics students practising energy-to-gram conversions
Questions
Which split should I choose?
There is no single best split. Only a split inside the AMDR (for example 20/50/30) matches the US adult reference ranges; the presets reflect popular approaches, and the widget says plainly when one lies outside them. Health conditions, training and preference matter more than the exact percentages.
Why does the balanced preset say it is outside the AMDR?
Its 40% carbohydrate is below the 45-65% AMDR for adults. The preset is kept because many coaches use it, but the widget reports the difference rather than calling it a guideline.
Why 4, 4 and 9 kcal per gram?
These are the Atwater general factors. FAO's 2003 report on food energy notes they can be off by 5-10% for some modern foods, but they remain the basis of most nutrition labels.
Can I preset calories for my readers?
Yes. Use v_calories=2200 and, for example, v_preset=highprotein in the embed URL.
Sources
- Food energy - methods of analysis and conversion factors (FAO Food and Nutrition Paper 77) - Food and Agriculture Organization of the United Nations, 2003 . Atwater general factors 4 / 4 / 9 kcal per gram
- Dietary Reference Intakes for Energy, Carbohydrate, Fiber, Fat, Fatty Acids, Cholesterol, Protein, and Amino Acids - Institute of Medicine / National Academies Press, 2005 . Adult AMDR: protein 10-35%, carbohydrate 45-65%, fat 20-35%
- A new predictive equation for resting energy expenditure in healthy individuals (Mifflin, St Jeor et al.) - American Journal of Clinical Nutrition 51(2):241-247, 1990 . Calorie estimate option
Cite or recommend this tool
If you reference this tool in an article, course or documentation, these formats are ready to copy. They are optional - nothing is added to your site unless you paste it.
A2Z Tools Macro Calculator https://a2z.tools/embed/macro-calculator
<a href="https://a2z.tools/embed/macro-calculator">A2Z Tools Macro Calculator</a>
[A2Z Tools Macro Calculator](https://a2z.tools/embed/macro-calculator)
Macro Calculator by A2Z Tools - https://a2z.tools/embed/macro-calculator
Related widgets
-
Maintenance calories (TDEE) and daily targets for gradual weight loss or gain.
-
Basal metabolic rate from Mifflin-St Jeor or the revised Harris-Benedict equation.
-
Estimated 1RM from a set of 1-12 reps by Epley and Brzycki, with a training-load table.
-
Body mass index with the WHO adult category and the healthy weight range for a height.
-
Body fat percentage from tape measurements with the US Navy method, plus ACE category.
-
Devine, Robinson, Miller and Hamwi ideal weights side by side, with the healthy BMI range.