The Ketogenic diet is a high-fat, moderate-protein, and low-carbohydrate nutritional approach. By restricting carbohydrates, your body enters a metabolic state called ketosis, where it burns fat for fuel instead of glucose.
How These Macros are Calculated
To provide you with the most accurate results, our calculator uses several key scientific metrics:
Basal Metabolic Rate (BMR): We use the Mifflin-St Jeor Equation to estimate how many calories your body burns at rest.
TDEE (Total Daily Energy Expenditure): Your BMR is multiplied by your activity level to determine your "maintenance" calories.
The Deficit: If your goal is weight loss, we apply a 10-20% deficit to your TDEE to ensure your body uses stored fat for energy.
Keto Examples & Calculations
Suppose you are an 80kg male, 180cm tall, 30 years old, with a sedentary lifestyle. Your BMR is roughly 1,790 calories. Your maintenance (TDEE) is ~2,148 calories.
Example Goal: Fat Loss (-20% deficit)
Total Daily Calories: 1,718 kcal
Carbs (Fixed): 20g (80 kcal)
Protein (1.6g/kg): 128g (512 kcal)
Fat (The Remainder): 125g (1,126 kcal)
Tips for Success
Net Carbs vs. Total Carbs: Only count net carbs (Total Carbs minus Fiber and Sugar Alcohols). This is what impacts blood sugar.
Protein is a Goal: Try to hit your protein number every day to preserve muscle mass.
Fat is a Lever: You don't have to eat all the fat if you feel full. Fat is there to provide satiety and energy.
Stay Hydrated: Keto has a diuretic effect. Drink plenty of water and keep your electrolytes (Sodium, Potassium, Magnesium) up.
function calculateKetoMacros() {
// Get Inputs
var gender = document.getElementById("ketoGender").value;
var age = parseFloat(document.getElementById("ketoAge").value);
var weight = parseFloat(document.getElementById("ketoWeight").value);
var height = parseFloat(document.getElementById("ketoHeight").value);
var activity = parseFloat(document.getElementById("ketoActivity").value);
var goalMult = parseFloat(document.getElementById("ketoGoal").value);
var targetCarbs = parseFloat(document.getElementById("ketoCarbs").value);
var proteinRatio = parseFloat(document.getElementById("ketoProteinRatio").value);
// Validate inputs
if (isNaN(age) || isNaN(weight) || isNaN(height) || isNaN(targetCarbs)) {
alert("Please fill in all fields with valid numbers.");
return;
}
// 1. Calculate BMR (Mifflin-St Jeor)
var bmr;
if (gender === "male") {
bmr = (10 * weight) + (6.25 * height) – (5 * age) + 5;
} else {
bmr = (10 * weight) + (6.25 * height) – (5 * age) – 161;
}
// 2. Calculate TDEE
var tdee = bmr * activity;
// 3. Target Calories based on goal
var targetCalories = Math.round(tdee * goalMult);
// 4. Protein Calculation (grams)
var proteinGrams = Math.round(weight * proteinRatio);
var proteinCals = proteinGrams * 4;
// 5. Carb Calculation (grams)
var carbGrams = targetCarbs;
var carbCals = carbGrams * 4;
// 6. Fat Calculation (The remaining calories)
// Formula: (Target Calories – Protein Calories – Carb Calories) / 9
var remainingCals = targetCalories – proteinCals – carbCals;
// Ensure calories don't go negative in extreme deficits
if (remainingCals < 0) {
remainingCals = 0;
}
var fatGrams = Math.round(remainingCals / 9);
var fatCals = fatGrams * 9;
// 7. Calculate Percentages
var totalCalsFromMacros = fatCals + proteinCals + carbCals;
var fatPerc = Math.round((fatCals / totalCalsFromMacros) * 100);
var proteinPerc = Math.round((proteinCals / totalCalsFromMacros) * 100);
var carbPerc = 100 – fatPerc – proteinPerc;
// Display Results
document.getElementById("resCalories").innerText = targetCalories;
document.getElementById("resFat").innerText = fatGrams + "g";
document.getElementById("resProtein").innerText = proteinGrams + "g";
document.getElementById("resNetCarbs").innerText = carbGrams + "g";
document.getElementById("percFat").innerText = fatPerc;
document.getElementById("percProtein").innerText = proteinPerc;
document.getElementById("percCarbs").innerText = carbPerc;
document.getElementById("ketoResults").style.display = "block";
// Smooth scroll to results
document.getElementById("ketoResults").scrollIntoView({ behavior: 'smooth', block: 'nearest' });
}