bmi.calc is a Body Mass Index (BMI) calculator project consisting of a web application and a command-line interface (CLI), both using the standard World Health Organization (WHO) BMI formula.
The project focuses on correctness, simplicity, and reusable core calculation logic shared across applications.
BMI is calculated using the global standard formula:
Β Β Β
Example:
A 60 kg person with height 165 cm (1.65 m) will resulting: 22.04 BMI (healthy weight)
Note
Height values entered in centimeters are internally normalized to meters before calculation.
| Category | BMI Range |
|---|---|
| Underweight | < 18.5 |
| Healthy | 18.5 - 24.9 |
| Overweight | 25 - 29.9 |
| Obesity | β₯ 30 |
Tip
In web app, the categories are displayed as sidebar (for desktop).
In CLI app, the categories are displayed as table with colored texts and can be shown using command as below:
bmi categoriesA simple browser-based BMI calculator that allows users to:
- Enter weight in kilograms (kg)
- Enter height in centimeters (cm) or meters (m)
- Instantly calculate BMI
- View BMI categories based on WHO classification
For more details about the web app, visit here.
A lightweight command-line tool designed for quick BMI calculations and scripting:
- Calculate BMI directly from terminal
- Support metric units (centimeters and meters) using
-uoption - Optional colored output
- JSON output support for automation
- View BMI categories based on WHO classification
For more details about the CLI app, visit here.
Need installation guide? Read here.
See examples
bmi calc 80 175
# OR:
bmi -w 80 -h 175Output:
BMI Result
ββββββββββ
ββββββββββββ¬βββββββββββββββββββββ
β BMI β Category β
ββββββββββββΌβββββββββββββββββββββ€
β 26.12 β Overweight β
ββββββββββββ΄βββββββββββββββββββββ
BMI Classification
ββββββββββββββββββ
ββββββββββββββββ¬βββββββββββββββββββββ
β Category β BMI Range β
ββββββββββββββββΌβββββββββββββββββββββ€
β Underweight β < 18.5 β
β Healthy β 18.5 - 24.9 β
β *Overweight β 25 - 29.9 β
β Obesity β β₯ 30 β
ββββββββββββββββ΄βββββββββββββββββββββ
Result in JSON format:
bmi calc 80 175 --jsonOutput:
{
"bmi": "26.12",
"category": "Overweight"
} ββ CLI-based App
β
ββ Logic Core β
β <apps/cli>
β βββββ @bmi-calc/cli
@bmi-calc/core βββ€
<packages/core> βββββ @bmi-calc/web
<apps/web>
β
β
Web-based App ββ
- @bmi-calc/core π‘’ Not an app, but core library. Contains logic core for these two applications.
- @bmi-calc/cli π‘’ A simple command-line interface app to calculate BMI.
- @bmi-calc/web π‘’ A web application provides BMI calculation with ease and fast UI response.
bun installbun @cli buildBuild for Development:
bun @web buildBuild for Production:
BASE_URL="/bmi.calc/" bun @web buildCaution
Specify the BASE_URL only if deploying the web app to a subpath (e.g., GitHub Pages).
bun @all buildImportant
The packaging process only applies to @bmi-calc/cli. The web application (@bmi-calc/web) is built and bundled separately using Vue and Vite.
Caution
The script file is still experimental.
The packaging process is not equivalent to a standard bun pm pack execution due to the projectβs architecture and custom bundling requirements. Use the provided script instead:
bun run pack cli --verboseOr:
bash ./scripts/pack.sh cli --verboseTip
Recommended to always run the script with --verbose flag to see what the script is doing.
If you want to know what commands are executed inside the script, you can set XTRACE=1 before the command.
For instance:
XTRACE=1 bun run pack cli --verboseIn this project architecture, the CLI depends on a locally bundled core package instead of pulling it from a registry. Because of this, the normal packing mechanisms (bun pm pack or npm pack) are not suitable since they are designed for publishing workflows, not for selective in-repo packaging.
The goal of this step is to replicate the behavior of the files field in package.json, but in reverse: instead of defining what to include during publish time, we remove everything except the required runtime assets. This ensures the bundled core remains minimal while still being fully functional.
This approach is necessary because:
- The core package is consumed as a local dependency during build time
- We only need compiled assets (such as
dist/, type definitions, and essential metadata) - Development files (tests, configs, sources, temporary build artifacts) would unnecessarily increase bundle size
bun pm pack/npm packwould require creating an intermediate tarball, which does not fit this workflow- The project uses a custom packaging pipeline rather than a registry-based distribution model
The cleanup logic will restores the core package to its original state. Any stashed changes will be applied back after the tarball is created.
bun @all testLint with ESLint
bun @all lintFormat using Prettier
bun formatLicensed under MIT license.