Nutrition Recipe Calculator
This calculator helps you determine the total nutritional content (calories, protein, carbohydrates, and fat) for your homemade recipes. By inputting each ingredient's quantity and its nutritional values per unit, you can get a comprehensive breakdown for the entire recipe and per serving. This is invaluable for meal planning, tracking macros, or adhering to specific dietary goals.
How to Use:
For each ingredient, enter its name, the quantity you are using in your recipe, and its nutritional values (Calories, Protein, Carbs, Fat) *per unit of that quantity*. For example, if you use 100 grams of chicken breast, enter '100' for Quantity and then the nutritional values for 100 grams of chicken breast. If you use 1 cup of flour, enter '1' for Quantity and the nutritional values for 1 cup of flour. Use the "Add Ingredient" button to include more items. Finally, specify the total number of servings your recipe yields.
Add Ingredient
Number of Servings:
Calculate Nutrition
Recipe Nutrition Summary
Total Recipe Nutrition:
Total Calories: kcal
Total Protein: g
Total Carbohydrates: g
Total Fat: g
Nutrition Per Serving:
Calories per Serving: kcal
Protein per Serving: g
Carbohydrates per Serving: g
Fat per Serving: g
Example Calculation: Chicken Stir-fry
Let's say you're making a chicken stir-fry and want to know its nutritional content.
You use the following ingredients:
Chicken Breast: 300 grams (165 kcal, 31g protein, 0g carbs, 3.6g fat per 100g)
Broccoli: 200 grams (34 kcal, 2.8g protein, 6.6g carbs, 0.4g fat per 100g)
Brown Rice: 150 grams (cooked) (123 kcal, 2.7g protein, 25.6g carbs, 0.9g fat per 100g)
Olive Oil: 1 tablespoon (14g) (120 kcal, 0g protein, 0g carbs, 14g fat per tablespoon)
And your recipe yields 4 servings.
Calculations:
Chicken Breast (300g):
Calories: (300/100) * 165 = 495 kcal
Protein: (300/100) * 31 = 93 g
Carbs: (300/100) * 0 = 0 g
Fat: (300/100) * 3.6 = 10.8 g
Broccoli (200g):
Calories: (200/100) * 34 = 68 kcal
Protein: (200/100) * 2.8 = 5.6 g
Carbs: (200/100) * 6.6 = 13.2 g
Fat: (200/100) * 0.4 = 0.8 g
Brown Rice (150g cooked):
Calories: (150/100) * 123 = 184.5 kcal
Protein: (150/100) * 2.7 = 4.05 g
Carbs: (150/100) * 25.6 = 38.4 g
Fat: (150/100) * 0.9 = 1.35 g
Olive Oil (1 tbsp):
Calories: 1 * 120 = 120 kcal
Protein: 1 * 0 = 0 g
Carbs: 1 * 0 = 0 g
Fat: 1 * 14 = 14 g
Total Recipe Nutrition:
Total Calories: 495 + 68 + 184.5 + 120 = 867.5 kcal
Total Protein: 93 + 5.6 + 4.05 + 0 = 102.65 g
Total Carbs: 0 + 13.2 + 38.4 + 0 = 51.6 g
Total Fat: 10.8 + 0.8 + 1.35 + 14 = 26.95 g
Per Serving (4 servings):
Calories per Serving: 867.5 / 4 = 216.88 kcal
Protein per Serving: 102.65 / 4 = 25.66 g
Carbs per Serving: 51.6 / 4 = 12.9 g
Fat per Serving: 26.95 / 4 = 6.74 g
This example demonstrates how the calculator aggregates the nutritional data from all ingredients to provide a complete picture of your recipe's health profile.
var ingredientCount = 1;
function addIngredientRow() {
ingredientCount++;
var ingredientInputs = document.getElementById("ingredientInputs");
var newRow = document.createElement("div");
newRow.className = "ingredient-row";
newRow.id = "ingredientRow" + ingredientCount;
newRow.style.cssText = "display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px dashed #eee;";
newRow.innerHTML = `
Ingredient Name:
Quantity (e.g., grams, cups):
Calories per Unit:
Protein per Unit (g):
Carbs per Unit (g):
Fat per Unit (g):
Remove
`;
ingredientInputs.appendChild(newRow);
}
function removeIngredientRow(rowId) {
var rowToRemove = document.getElementById(rowId);
if (rowToRemove) {
rowToRemove.parentNode.removeChild(rowToRemove);
}
}
function calculateNutrition() {
var totalCalories = 0;
var totalProtein = 0;
var totalCarbs = 0;
var totalFat = 0;
var errorMessage = document.getElementById("errorMessage");
errorMessage.style.display = "none";
errorMessage.innerHTML = "";
var hasError = false;
for (var i = 1; i <= ingredientCount; i++) {
var quantityInput = document.getElementById("quantity" + i);
var caloriesPerUnitInput = document.getElementById("caloriesPerUnit" + i);
var proteinPerUnitInput = document.getElementById("proteinPerUnit" + i);
var carbsPerUnitInput = document.getElementById("carbsPerUnit" + i);
var fatPerUnitInput = document.getElementById("fatPerUnit" + i);
// Check if the row exists (it might have been removed)
if (!quantityInput) {
continue;
}
var quantity = parseFloat(quantityInput.value);
var caloriesPerUnit = parseFloat(caloriesPerUnitInput.value);
var proteinPerUnit = parseFloat(proteinPerUnitInput.value);
var carbsPerUnit = parseFloat(carbsPerUnitInput.value);
var fatPerUnit = parseFloat(fatPerUnitInput.value);
if (isNaN(quantity) || isNaN(caloriesPerUnit) || isNaN(proteinPerUnit) || isNaN(carbsPerUnit) || isNaN(fatPerUnit) ||
quantity < 0 || caloriesPerUnit < 0 || proteinPerUnit < 0 || carbsPerUnit < 0 || fatPerUnit < 0) {
errorMessage.innerHTML = "Please enter valid positive numbers for all ingredient quantities and nutritional values.";
errorMessage.style.display = "block";
hasError = true;
break;
}
totalCalories += quantity * caloriesPerUnit;
totalProtein += quantity * proteinPerUnit;
totalCarbs += quantity * carbsPerUnit;
totalFat += quantity * fatPerUnit;
}
if (hasError) {
document.getElementById("nutritionResult").style.display = "none";
return;
}
var numberOfServingsInput = document.getElementById("numberOfServings");
var numberOfServings = parseFloat(numberOfServingsInput.value);
if (isNaN(numberOfServings) || numberOfServings <= 0) {
errorMessage.innerHTML = "Please enter a valid positive number for servings.";
errorMessage.style.display = "block";
document.getElementById("nutritionResult").style.display = "none";
return;
}
var servingCalories = totalCalories / numberOfServings;
var servingProtein = totalProtein / numberOfServings;
var servingCarbs = totalCarbs / numberOfServings;
var servingFat = totalFat / numberOfServings;
document.getElementById("totalCalories").innerText = totalCalories.toFixed(2);
document.getElementById("totalProtein").innerText = totalProtein.toFixed(2);
document.getElementById("totalCarbs").innerText = totalCarbs.toFixed(2);
document.getElementById("totalFat").innerText = totalFat.toFixed(2);
document.getElementById("servingCalories").innerText = servingCalories.toFixed(2);
document.getElementById("servingProtein").innerText = servingProtein.toFixed(2);
document.getElementById("servingCarbs").innerText = servingCarbs.toFixed(2);
document.getElementById("servingFat").innerText = servingFat.toFixed(2);
document.getElementById("nutritionResult").style.display = "block";
}
// Initial calculation with example values
calculateNutrition();