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.…