Macro Nutrient Calculator Formula

Understand the math behind the macro nutrient calculator. Each variable explained with a worked example.

Formulas Used

Protein (grams)

protein_grams = calories * protein_pct / 100 / 4

Carbs (grams)

carbs_grams = calories * carbs_pct / 100 / 4

Fat (grams)

fat_grams = calories * fat_pct / 100 / 9

Protein Calories

protein_cal = calories * protein_pct / 100

Carbs Calories

carbs_cal = calories * carbs_pct / 100

Fat Calories

fat_cal = calories * fat_pct / 100

Variables

VariableDescriptionDefault
caloriesDaily Calories(cal)2500
protein_pctProtein %(%)30
carbs_pctCarbs %(%)40
fat_pctFat %(%)30

How It Works

How Macros Are Calculated

Macronutrients provide calories at different rates:

  • Protein: 4 calories per gram
  • Carbohydrates: 4 calories per gram
  • Fat: 9 calories per gram
  • Formula

    Grams = (Total Calories x Macro %) / Calories per gram

    Ensure your percentages add up to 100%.

    Worked Example

    2,500 calories with a 30/40/30 split (protein/carbs/fat).

    calories = 2500protein_pct = 30carbs_pct = 40fat_pct = 30
    1. 01Protein: 2500 x 0.30 / 4 = 188g (750 cal)
    2. 02Carbs: 2500 x 0.40 / 4 = 250g (1000 cal)
    3. 03Fat: 2500 x 0.30 / 9 = 83g (750 cal)

    Ready to run the numbers?

    Open Macro Nutrient Calculator