This calculator helps estimate the number of calories burned during a workout based on your heart rate, duration, and personal metrics. Understanding your calorie expenditure can be a valuable tool for fitness tracking, weight management, and optimizing your training intensity.
Male
Female
function calculateCalories() {
var age = parseFloat(document.getElementById("age").value);
var weightKg = parseFloat(document.getElementById("weightKg").value);
var gender = document.getElementById("gender").value;
var heartRate = parseFloat(document.getElementById("heartRate").value);
var durationMinutes = parseFloat(document.getElementById("durationMinutes").value);
var caloriesBurned = 0;
if (isNaN(age) || isNaN(weightKg) || isNaN(heartRate) || isNaN(durationMinutes)) {
document.getElementById("result").innerHTML = "Please enter valid numbers for all fields.";
return;
}
// Using a simplified MET (Metabolic Equivalent of Task) approximation based on heart rate and gender.
// These formulas are approximations and can vary significantly.
var met;
if (gender === "male") {
met = (heartRate * 0.028) + 0.01 * age + 0.494;
} else { // female
met = (heartRate * 0.019) + 0.01 * age + 0.139;
}
// Ensure MET is within a reasonable range for exercise
if (met 15) met = 15; // Cap MET to avoid unrealistic values
// Calories burned per minute = MET * 3.5 * weightKg / 200
var caloriesPerMinute = met * 3.5 * weightKg / 200;
caloriesBurned = caloriesPerMinute * durationMinutes;
document.getElementById("result").innerHTML = "Estimated Calories Burned: " + caloriesBurned.toFixed(2) + " kcal";
}
.calculator-wrapper {
font-family: sans-serif;
border: 1px solid #ccc;
padding: 20px;
border-radius: 8px;
max-width: 500px;
margin: 20px auto;
background-color: #f9f9f9;
}
.calculator-wrapper h2 {
text-align: center;
margin-bottom: 20px;
color: #333;
}
.calculator-wrapper p {
margin-bottom: 20px;
color: #555;
line-height: 1.6;
}
.calculator-inputs {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 15px;
margin-bottom: 20px;
}
.input-group {
display: flex;
flex-direction: column;
}
.input-group label {
margin-bottom: 5px;
font-weight: bold;
color: #444;
}
.input-group input[type="number"],
.input-group select {
padding: 10px;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 1rem;
}
.calculator-wrapper button {
background-color: #4CAF50;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1.1rem;
display: block;
width: 100%;
margin-top: 10px;
transition: background-color 0.3s ease;
}
.calculator-wrapper button:hover {
background-color: #45a049;
}
.calculator-result {
margin-top: 25px;
padding: 15px;
background-color: #e7f3fe;
border-left: 6px solid #2196F3;
color: #333;
font-size: 1.2rem;
font-weight: bold;
text-align: center;
border-radius: 4px;
}