Every fitness app needs the same calculations — BMI, TDEE, one-rep max, macros, heart rate zones. But the npm ecosystem for fitness math is surprisingly bad. Most packages are abandoned, incomplete, or lack TypeScript support.
So we built @finegym/fitness-calc and open-sourced it.
What's included:
| Module | Details |
|---|---|
| BMI | WHO classification, healthy weight ranges, metric + imperial |
| BMR | 3 formulas (Mifflin-St Jeor, Harris-Benedict, Katch-McArdle) |
| TDEE | 6 activity levels from sedentary to extra active |
| 1RM | 7 formulas (Epley, Brzycki, Lombardi, Mayhew, O'Conner, Wathan, Lander) |
| Macros | 6 diet presets + custom ratios, maintenance/cutting/bulking |
| Body Fat | US Navy method + BMI-derived estimation |
| Heart Rate | Standard + Karvonen models, 5 training zones |
| Calories | 30+ activities with MET values |
| Pace | Running pace, speed, race time prediction (Riegel formula) |
| Ideal Weight | 4 formulas (Robinson, Miller, Devine, Hamwi) |
| Water Intake | Activity-adjusted daily recommendations |
| Conversions | Weight, height, distance, temperature |
Quick example:
import { calculateOneRepMax, calculateAllFormulas } from '@finegym/fitness-calc';
// Bench press: 100kg for 5 reps
const result = calculateOneRepMax(100, 5);
// { oneRepMax: 116.7, formula: 'epley', percentages: { 100: 116.7, 95: 110.9, ... } }
// Compare all 7 formulas
const all = calculateAllFormulas(100, 5);
// { epley: 116.7, brzycki: 112.5, lombardi: 117.5, ... }
Technical specs:
- Zero dependencies
- ~20KB bundle
- Dual CJS/ESM
- Full TypeScript declarations
- 85 tests
- CI on Node 18/20/22
Install:
npm install @finegym/fitness-calc
All formulas are backed by peer-reviewed research (Mifflin 1990, Tanaka 2001, Epley, Brzycki, etc.). Every input is validated with descriptive error messages.
We built this at FineGym (https://www.finegym.io) while building our gym management platform. Rather than keeping it internal, we decided the fitness developer community would benefit from having a single, well-maintained library.
Links:
- GitHub: https://github.com/finegym-io/fitness-calc
- npm: https://www.npmjs.com/package/@finegym/fitness-calc
MIT licensed. PRs welcome — especially for new formulas, additional activities, and sport-specific calculations.
Top comments (0)