DEV Community

Cover image for How I Built a Fast Calorie & TDEE Calculator in Vanilla JavaScript
Solangi Waqas
Solangi Waqas

Posted on

How I Built a Fast Calorie & TDEE Calculator in Vanilla JavaScript

Calculating daily caloric expenditure accurately is essential for fitness tracking. I built a lightweight, client-side Calorie & TDEE Calculator using standard JavaScript and the Mifflin-St Jeor formula.

Why Mifflin-St Jeor Formula?

It is considered one of the most accurate equations for estimating Basal Metabolic Rate (BMR):

  • Men: BMR = (10 × weight in kg) + (6.25 × height in cm) - (5 × age) + 5
  • Women: BMR = (10 × weight in kg) + (6.25 × height in cm) - (5 × age) - 161

Core JavaScript Logic

function calculateTDEE(weight, height, age, gender, activityLevel) {
let bmr = (10 * weight) + (6.25 * height) - (5 * age);
bmr = (gender === 'male') ? bmr + 5 : bmr - 161;
return Math.round(bmr * activityLevel);
}

Live Tool Demo

You can test the fully responsive web tool live here:
https://www.globaltoolsbox.online/2026/08/calorie-calculator-tdee.html

Feedback and suggestions for new web utilities are always welcome!

Top comments (0)