Sedentary (little to no exercise)
Lightly Active (light exercise/sports 1-3 days/week)
Moderately Active (moderate exercise/sports 3-5 days/week)
Very Active (hard exercise/sports 6-7 days/week)
Extra Active (very hard exercise/sports & physical job)
Lose Weight
Maintain Weight
Gain Weight
Your Ketogenic Macros
Please enter your details and click "Calculate Macros".
Understanding Ketogenic Diet Macros
The ketogenic diet, often called "keto," is a very low-carbohydrate, high-fat eating pattern. The primary goal of the keto diet is to shift your body's primary fuel source from glucose (derived from carbohydrates) to ketones (produced from fat breakdown). This metabolic state is known as ketosis.
To achieve and maintain ketosis, precise macronutrient ratios are crucial. Macronutrients (macros) refer to the three main types of food your body needs in large amounts: carbohydrates, protein, and fats. Calculating your individual macro targets is essential for success on the ketogenic diet.
The Calculation Process
Our calculator uses a standard approach involving several steps:
Basal Metabolic Rate (BMR): We first estimate your BMR, the number of calories your body needs at rest to maintain basic functions. The Mifflin-St Jeor equation is commonly used for this:
For Men: BMR = (10 × weight in kg) + (6.25 × height in cm) – (5 × age in years) + 5
For Women: BMR = (10 × weight in kg) + (6.25 × height in cm) – (5 × age in years) – 161
Total Daily Energy Expenditure (TDEE): Your BMR is then adjusted for your activity level to estimate your TDEE. This is the total number of calories you burn in a day. We use standard multipliers:
Sedentary: BMR × 1.2
Lightly Active: BMR × 1.375
Moderately Active: BMR × 1.55
Very Active: BMR × 1.725
Extra Active: BMR × 1.9
Calorie Adjustment for Goal: Your TDEE is then adjusted based on your weight goal. A deficit of approximately 500 calories per day is typically recommended for weight loss (leading to about 1 lb of fat loss per week), while a surplus might be added for weight gain. For maintenance, your TDEE is used directly. For simplicity in this calculator, we'll aim for a moderate deficit/surplus if needed, but the core macro percentages are the focus.
Macronutrient Breakdown: Finally, the target calorie intake is distributed among carbohydrates, protein, and fats according to your specified percentages.
Carbohydrates: Each gram of carbohydrate provides 4 calories.
Protein: Each gram of protein provides 4 calories.
Fats: Each gram of fat provides 9 calories.
The formula for calculating grams of each macronutrient is:
Low Carbohydrates: Typically, net carbs are kept below 20-50 grams per day. This drastic reduction forces the body to switch to burning fat for energy.
Moderate Protein: Protein is essential for preserving muscle mass, but consuming too much can be converted into glucose (gluconeogenesis), potentially hindering ketosis. The "moderate" amount ensures adequate protein without excessive intake.
High Fats: Fats become the primary energy source on keto. This macro provides the bulk of your calories and helps with satiety, making it easier to adhere to the diet.
This calculator provides personalized estimates to guide you on your ketogenic journey. Remember to consult with a healthcare professional or registered dietitian before making significant changes to your diet.
function calculateMacros() {
var age = parseFloat(document.getElementById("age").value);
var gender = document.getElementById("gender").value;
var weightKg = parseFloat(document.getElementById("weightKg").value);
var heightCm = parseFloat(document.getElementById("heightCm").value);
var activityLevel = document.getElementById("activityLevel").value;
var goal = document.getElementById("goal").value;
var carbPercentage = parseFloat(document.getElementById("carbPercentage").value);
var proteinPercentage = parseFloat(document.getElementById("proteinPercentage").value);
var fatPercentage = parseFloat(document.getElementById("fatPercentage").value);
var macrosOutput = document.getElementById("macrosOutput");
macrosOutput.innerHTML = ""; // Clear previous results
// — Input Validation —
if (isNaN(age) || isNaN(weightKg) || isNaN(heightCm) || isNaN(carbPercentage) || isNaN(proteinPercentage) || isNaN(fatPercentage)) {
macrosOutput.innerHTML = 'Please enter valid numbers for all required fields.';
return;
}
if (age <= 0 || weightKg <= 0 || heightCm <= 0) {
macrosOutput.innerHTML = 'Age, weight, and height must be positive values.';
return;
}
if (carbPercentage < 0 || proteinPercentage < 0 || fatPercentage < 0 || (carbPercentage + proteinPercentage + fatPercentage) !== 100) {
macrosOutput.innerHTML = 'Macro percentages must be non-negative and sum up to 100%.';
return;
}
// — Calculate BMR (Mifflin-St Jeor Equation) —
var bmr;
if (gender === "male") {
bmr = (10 * weightKg) + (6.25 * heightCm) – (5 * age) + 5;
} else { // female
bmr = (10 * weightKg) + (6.25 * heightCm) – (5 * age) – 161;
}
// — Calculate TDEE —
var tdee;
var activityMultiplier;
switch (activityLevel) {
case "sedentary":
activityMultiplier = 1.2;
break;
case "light":
activityMultiplier = 1.375;
break;
case "moderate":
activityMultiplier = 1.55;
break;
case "very_active":
activityMultiplier = 1.725;
break;
case "extra_active":
activityMultiplier = 1.9;
break;
default:
activityMultiplier = 1.2; // Default to sedentary
}
tdee = bmr * activityMultiplier;
// — Adjust calories for goal (simplified approach) —
var targetCalories = tdee;
var calorieAdjustment = 0;
if (goal === "lose") {
calorieAdjustment = -500; // Approx. deficit for weight loss
} else if (goal === "gain") {
calorieAdjustment = 300; // Approx. surplus for weight gain
}
targetCalories = tdee + calorieAdjustment;
// Ensure target calories are not excessively low or negative
if (targetCalories < 1200) {
targetCalories = 1200;
}
// — Calculate Macro Grams —
var caloriesFromCarbs = targetCalories * (carbPercentage / 100);
var caloriesFromProtein = targetCalories * (proteinPercentage / 100);
var caloriesFromFat = targetCalories * (fatPercentage / 100);
var gramsCarbs = caloriesFromCarbs / 4;
var gramsProtein = caloriesFromProtein / 4;
var gramsFat = caloriesFromFat / 9;
// — Display Results —
var resultHtml = '