Menu

1 / 2

The Deurenberg BMI-to-Body-Fat Formula in JavaScript: How to Implement It, and When Not to Trust It

DEV Community: webdev·Charlotte Nelson·about 10 hours ago
#yo1jPJZ5
#devtowebdev#devto#dev#body#formula
Long article (4136 words) — no AI summary yet.
Reading 0:00
15s threshold

If you have built a BMI calculator, the next feature request is almost always "can it show body fat too?" The usual answer, in tutorials, fitness apps and Stack Overflow snippets, is a single line of arithmetic: the Deurenberg formula, which turns BMI, age and sex into an estimated body fat percentage.

It is a real, peer-reviewed equation, and implementing it takes about thirty seconds. Implementing it responsibly takes a bit longer. The formula was fitted to a specific group of people, it has a published error of about four percentage points, it was never meant for children, and it knows nothing about muscle. None of that is visible in the one-liner.

This post covers both halves: a small, framework-free JavaScript module for the Deurenberg body fat formula, the input validation and refusals it needs, a node --test suite with hand-checked golden values, and the labeling rules that keep the UI from claiming more than the math supports. Nothing here is medical advice.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.