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)

    Frequently Asked Questions

    What is a good macro split?

    Common splits: 30/40/30 (balanced), 40/30/30 (high protein for muscle building), 25/50/25 (high carb for endurance athletes), and 5/25/70 (ketogenic). Your ideal split depends on your goals, activity type, and what you can sustain long-term.

    Why should macros add up to 100%?

    Protein, carbs, and fat collectively make up all caloric intake, so they must total 100%. If your percentages do not add up, your calorie targets will not align with your macro gram targets.

    How many grams of protein should I eat per day?

    General guidelines: 0.36 g per pound (0.8 g/kg) for sedentary adults (the RDA), 0.7-0.8 g per pound (1.6-1.8 g/kg) for those building muscle, and up to 1 g per pound for cutting phases. Most research shows benefits plateau above 1 g/lb body weight.

    Does the source of macros matter, or just the totals?

    Both matter. Total grams drive weight and body composition changes, but food quality affects health, satiety, and performance. For example, 50g of protein from chicken vs. a protein shake have different micronutrient profiles. Prioritizing whole foods within your macro targets is the best approach.

    Learn More

    Guide

    How to Calculate Daily Calories: A Complete Guide

    Learn how to calculate your daily calorie needs using BMR, TDEE, and activity multipliers. Understand calorie deficits, surpluses, and how to set targets for your goals.

    Ready to run the numbers?

    Open Macro Nutrient Calculator