@aadifit/tdee-calc
v1.0.0
Published
Zero-dependency TDEE, BMR and macro calculator — Mifflin-St Jeor, Katch-McArdle and Harris-Benedict formulas.
Maintainers
Readme
@aadifit/tdee-calc
Zero-dependency TDEE, BMR and macro calculator for Node.js (and any bundler — webpack, esbuild, Vite — for browser use). Implements the three formulas actually used in clinical and fitness practice — Mifflin-St Jeor, Katch-McArdle and Harris-Benedict — plus a goal-based macro split (protein/carb/fat grams). No build step, no dependencies, ~150 lines.
Install
npm install @aadifit/tdee-calcUsage
const { mifflinStJeor, tdee, macroSplit } = require('@aadifit/tdee-calc');
const bmr = mifflinStJeor({ weightKg: 80, heightCm: 180, age: 30, sex: 'male' });
// 1780
const maintenance = tdee(bmr, 'moderate'); // 'sedentary'|'light'|'moderate'|'active'|'very_active'
// 2759
const macros = macroSplit(maintenance, { weightKg: 80, goal: 'maintain' }); // 'cut'|'maintain'|'bulk'
// { goal: 'maintain', targetKcal: 2759, proteinG: 160, fatG: 86, carbG: 336 }If you know your body fat percentage, katchMcArdle is more accurate than
formulas based on height/weight alone:
const { katchMcArdle } = require('@aadifit/tdee-calc');
katchMcArdle({ weightKg: 80, bodyFatPct: 15 }); // 1838.8API
mifflinStJeor({ weightKg, heightCm, age, sex }) → number
The most accurate general-population BMR formula in validation studies (Frankenfield et al., 2005, J Am Diet Assoc 105(5):775-89).
katchMcArdle({ weightKg, bodyFatPct }) → number
Uses lean body mass. More accurate than height/weight-based formulas for people with a known, reliable body fat percentage.
harrisBenedict({ weightKg, heightCm, age, sex }) → number
The 1984 revision (Roza & Shizgal). Included for compatibility with older
tools; prefer mifflinStJeor for new work.
tdee(bmr, activityLevel) → number
activityLevel is one of sedentary (1.2) · light (1.375) ·
moderate (1.55) · active (1.725) · very_active (1.9).
macroSplit(tdeeKcal, { weightKg, goal, proteinPerKg?, fatPct?, kcalAdjustPct? }) → { goal, targetKcal, proteinG, fatG, carbG }
goal is cut (-20% kcal, 2.2 g/kg protein) · maintain · bulk (+10% kcal,
1.8 g/kg protein). Override any default per call.
Every function throws a TypeError with a specific message on bad input
(negative weight, unknown activity level, etc.) rather than returning NaN.
Why this exists
Most TDEE calculators live behind a wall of ads with no way to verify the math or reuse it programmatically. This package is the calculation engine only — MIT licensed, unit-tested against hand-derived reference values, and usable in any Node or browser project. It's maintained by AadiFit, where you can try the full calculator with body composition tracking, activity logging and an adaptive plan built around your numbers at aadifit.com/tdee-calculator.
Testing
npm test16 tests, each checked against hand-derived reference values for every
formula (see test/formulas.test.js).
License
MIT © AadiFit
