Skip to content
Get the app

How we calculate

Last updated

Every number on CalorTracker's food pages and calculators comes from one of two places: a published data set, or a formula written out below. This page describes what our code does, step by step, with worked examples computed by the same code. The outside sources are listed on sources, and how we write and correct content is on the editorial policy.

Food data: USDA FoodData Central

The values on the food pages are read from USDA FoodData Central, the U.S. Department of Agriculture's public-domain database. A script downloads the USDA files and writes one data file per food; nothing is typed by hand, and a re-run on the same files gives identical output.

Which datasets

We read three: Foundation Foods, SR Legacy (final since April 2018) and FNDDS, the Survey Foods used for mixed dishes as eaten. Of our 461 foods, 403 come from SR Legacy, 2 from Foundation Foods and 56 from FNDDS. We prefer SR Legacy or Foundation, and use FNDDS for prepared dishes.

How we pick an FDC id

The list of foods is curated by hand. For each food we choose one FDC id, matching the cooking state the page means (a page that gives "1 cup cooked" uses the cooked record). One FDC id belongs to one page, and the page links its FDC record so you can check it. The id is a choice; the values under it are USDA's.

Per 100 grams

USDA reports nutrients per 100 g of edible food, and that is what we store. We do not scale, average or adjust them. Calories use USDA's energy value; where a record has none, the Atwater General and then the Atwater Specific energy value USDA publishes. A nutrient USDA did not report is kept as missing, never as zero, and the import stops if a nutrient's unit in a new USDA release differs from the unit we label it with.

Any other amount is straight proportion from the per-100 g value: calories are rounded to a whole number and macros to 0.1 g. The amount tables and the amount calculator on each food page use one function, so they agree. Example, using Almonds at 579 kcal and 21.15 g protein per 100 g: 1 oz (28.3495 g) is 164 kcal and 6 g protein.

Portions

Household portions such as "1 cup" or "1 medium" are USDA's own measures with USDA's gram weight; we do not estimate weights. We drop survey bookkeeping rows ("Quantity not specified", "Guideline amount" recipe allowances), yield weights, rows with no positive weight and repeated labels. Which portion a page leads with is an editorial choice among USDA's portions. For Almonds, USDA lists "1 cup, whole" as 143 g, which is 828 kcal.

Percent Daily Value

%DV is the amount divided by the FDA Daily Value for adults and children 4 years and older (21 CFR 101.9), rounded to a whole percent, and shown as "<1%" for a trace that rounds to zero. Nutrients with no Daily Value, such as total sugars, show no %DV. Example: Almonds has 269 mg of calcium per 100 g; the Daily Value is 1300 mg, so that is 21%.

Energy density and net carbs

Energy density is calories per gram, banded as the CDC does: very low (0 to 0.6 kcal/g), low (0.6 to 1.5 kcal/g), medium (1.5 to 4 kcal/g), high (above 4 kcal/g). Net carbs are total carbohydrate minus fiber, never below zero.

Calculator formulas

The calculators run in your browser using one shared set of functions. Everything is computed in kilograms and centimetres; pounds and inches are converted first (1 lb = 0.45359237 kg, 1 in = 2.54 cm). The worked examples use one person, a 30-year-old man, 80 kg, 180 cm, so the figures chain from one section to the next.

BMR: Mifflin-St Jeor

BMR (kcal per day) = 10 × weight in kg + 6.25 × height in cm − 5 × age in years, then + 5 for men or − 161 for women, rounded to a whole number. Source: Mifflin and colleagues, 1990. Example: 10 × 80 + 6.25 × 180 − 5 × 30 + 5 = 1,780 kcal.

TDEE: activity multipliers

TDEE = BMR × an activity multiplier, rounded to a whole number. The multipliers are:

Activity multipliers used for TDEE
Activity levelMultiplierMeaning
Sedentary1.2Little or no exercise, desk job
Lightly active1.375Light exercise 1-3 days/week
Moderately active1.55Moderate exercise 3-5 days/week
Very active1.725Hard exercise 6-7 days/week
Extra active1.9Physical job or 2x/day training

Example at 1.55 ("Moderately active"): 1,780 × 1.55 = 2,759 kcal. The multipliers are the long-standing conventional factors; they describe an average, not you, which is why the result is a starting point.

Calorie goals and the deficit

A calorie goal is TDEE plus or minus a fixed daily amount: −1,000, −500, −250, 0, +250 or +500 kcal. The weekly change in body weight is estimated as the daily amount × 7 ÷ 7,700 kg, treating a kilogram of body weight as 7,700 kcal (about 3,500 kcal per pound). This is a rule of thumb: real weight change adjusts as your body adapts, so treat it as a rough pace. Example: TDEE 2,759 − 500 = 2,259 kcal a day, about 0.45 kg (1 lb) lost per week.

Macros

The macro calculator splits calories into protein, carbohydrate and fat by percentage, then converts to grams at 4 kcal per gram for protein and carbohydrate and 9 kcal per gram for fat. The default split is 30% protein, 40% carbohydrate, 30% fat. It is a preset, not a finding that this split is best. Above a BMI of 30, protein stops at the top of the protein calculator's range for your goal and carbohydrate takes the rest.

Body fat: U.S. Navy method

With all measurements in centimetres, men: body fat % = 495 ÷ (1.0324 − 0.19077 × log10(waist − neck) + 0.15456 × log10(height)) − 450. Women: 495 ÷ (1.29579 − 0.35004 × log10(waist + hip − neck) + 0.221 × log10(height)) − 450. The result is rounded to 0.1; if the inputs give no valid number we show none. Source: Hodgdon and Beckett, 1984. Example: 180 cm tall, neck 38 cm, waist 85 cm gives 16.1%. The category labels (essential fat, athletes, fitness, acceptable, obesity) follow the ACE bands. Tape-measure methods are estimates and can be off by several percentage points compared with a DEXA scan.

Ideal weight: Devine, Robinson, Miller, Hamwi

Each formula starts from a base weight at 5 feet (60 inches) and adds a fixed amount for every inch above it. We show all four, because they disagree, and none is a target for any individual.

Ideal body weight formulas as the calculator applies them (kg, height over 60 in)
FormulaMenWomen
Devine (1974)50 + 2.3 per inch45.5 + 2.3 per inch
Robinson (1983)52 + 1.9 per inch49 + 1.7 per inch
Miller (1983)56.2 + 1.41 per inch53.1 + 1.36 per inch
Hamwi (1964)48 + 2.7 per inch45.5 + 2.2 per inch

Example for a man 180 cm tall (about 70.9 in): Robinson 72.6 kg, Miller 71.5 kg, Devine 75 kg, Hamwi 77.3 kg. The BMI page separately shows the weight range that keeps BMI between 18.5 and 24.9 at your height.

Protein

The protein calculator multiplies your body weight by a range per kilogram that depends on your goal. These ranges are rules of thumb written into the calculator, not the output of one study. Body weight counts up to 100 kg, or up to a BMI of 30 on the calculators that ask for your height, and no range goes above 240 g, because extra body weight is mostly fat, which needs far less protein than muscle. For 80 kg:

Protein ranges per kilogram, applied to 80 kg
Goalg per kgGrams per day at 80 kg
Maintain weight1.2 to 1.696 to 128
Lose weight1.6 to 2.2128 to 176
Build muscle1.6 to 2.2128 to 176
Endurance or strength athlete1.8 to 2.4144 to 192

Water

Daily water = 33 ml per kg of body weight + 350 ml for every 30 minutes of exercise, then + 10% in a hot climate, rounded to the nearest 10 ml. The part for body weight stops at 4,000 ml, because extra weight is mostly fat, which needs far less water than muscle. This is a rule of thumb, not a medical recommendation. Example: 80 kg and 30 minutes of exercise gives 2,990 ml (3 L) in a temperate climate and 3,290 ml in a hot one.

Energy and weight tools

These tools share one set of rules. Maintenance calories are the TDEE above. A change to them is a fixed number of calories a day, converted to a weekly change in weight at 7,700 kcal per kilogram. The figure goes back to Wishnofsky (1958), and Hall and colleagues (2011) showed it overstates long-run change because a lighter body burns less, so every timeline is the earliest sensible estimate, not a forecast. All the examples below use the same 30-year-old man (80 kg, 180 cm, TDEE 2,759 kcal).

The floors. A weight-loss target is never set below 1,200 kcal a day for women or 1,500 kcal for men, and the largest deficit offered is 1,000 kcal a day. If a goal would need more, the tools show the most they will suggest and how long the goal takes at that pace. If your estimated maintenance is already at or under the floor, they offer no deficit. These are the same minimums the calorie deficit page uses; going lower is something to do only with medical supervision.

Calorie calculator. Target = TDEE − 250, 500, 1000 (lose), TDEE (maintain) or TDEE + 250 or 500 (gain). Example, losing at 500 kcal: 2,759 − 500 = 2,259 kcal, 753 kcal at each of three meals. The page that answers "maintenance calories" is the TDEE calculator.

Weight loss calculator. Needed deficit = weight to lose × 7,700 ÷ (weeks × 7). Example: 8 kg in 12 weeks needs 733 kcal a day, so 2,026 kcal. The same 8 kg in 4 weeks would need 2,200 kcal a day, over the limit, so the tool shows 1,759 kcal and says the goal then takes about 9 weeks. A goal weight under the BMI 18.5 weight for your height is flagged.

Weight gain calculator. Target = TDEE + the surplus; weekly gain = surplus × 7 ÷ 7,700. Example: 2,759 + 500 = 3,259 kcal, about 0.45 kg a week, so 5 kg takes about 11 weeks. The calorie surplus calculator is this page.

Calorie cycling calculator. The weekly average is the calorie calculator's target. Low day = average − gap × high days ÷ 7; high day = low day + gap. Example at 2,259 kcal on average, two high days and a 400 kcal gap: 2,545 on high days and 2,145 on the other five, 15,815 kcal for the week against a target of 15,813. No day goes under the floor.

Intermittent fasting calculator. Eating window = 24 − fasting hours, added to the first meal time. It is arithmetic on the clock and uses no health data. Example: a 16:8 schedule from 12:00 pm ends at 8:00 pm.

Weight loss percentage calculator. Percentage = (start − current) ÷ start × 100. Example: 80 kg to 72 kg is 10%, 1 kg a week over 8 weeks. It notes a pace above 0.9 kg a week (2 lb), the top of the 1 to 2 pounds a week the CDC describes as steady loss.

How long to lose weight calculator. Weeks = weight to lose ÷ weekly pace, rounded up; months = weeks × 7 ÷ 30.44. Example: 10 kg at 0.5 kg a week is 20 weeks, about 4.6 months. Paces above 1 kg a week are not accepted.

Macro tools

These tools turn the calorie target of the calorie calculator into grams. The conversion is 4 kcal per gram of protein and carbohydrate and 9 kcal per gram of fat. Where they set a calorie target for losing weight they use the same floors as the energy tools (1,200 kcal for women, 1,500 kcal for men). Protein, wherever it is set from body weight, is the middle of the protein calculator's range for the goal. All the examples below use the same 30-year-old man (80 kg, 180 cm, TDEE 2,759 kcal) losing weight at 500 kcal a day.

Keto calculator. Calories from the calorie calculator, net carbs fixed at 20, 30 or 50 g (the very-low-carbohydrate line in Bueno and colleagues, 2013, is 50 g), protein from body weight, and fat = (calories − 4 × protein − 4 × carbs) ÷ 9. Example at 30 g: 2,259 kcal, 152 g of protein (1.9 g per kg), so 170 g of fat. If protein and carbs already use every calorie it shows a message instead of a negative fat figure. It makes no claims about ketosis.

Cutting and bulking calculators. Calories = TDEE − the deficit (cutting) or + the surplus (bulking). Protein = body weight × 1.9 g per kg; fat = calories × the chosen share (20, 25 or 30%) ÷ 9; carbohydrate = the remaining calories ÷ 4. The order follows sports-nutrition reviews (Helms, Aragon and Fitschen, 2014; Iraki and colleagues, 2019); their numbers are not used. Example, cutting at 25% fat: 2,259 kcal, 152 g protein, 63 g fat, 271 g carbs. Bulking at +500: 3,259 kcal, 152 g, 91 g and 458 g.

Carb, fat and fiber calculators. Carbohydrate = 45 to 65% of calories ÷ 4 and fat = 20 to 35% of calories ÷ 9, the Acceptable Macronutrient Distribution Ranges of the Institute of Medicine (Dietary Reference Intakes, 2005). The carbohydrate Recommended Dietary Allowance of 130 g is flagged when the range falls under it. Saturated fat is capped at 10% of calories, from the Dietary Guidelines for Americans. Fiber = calories ÷ 1,000 × 14 g, the ratio behind the Institute of Medicine's Adequate Intake, shown beside the fixed Adequate Intake for the reader's sex and age. Example at 2,259 kcal: carbohydrate 254 to 367 g, fat 50 to 88 g (saturated up to 25 g), fiber 32 g against an Adequate Intake of 38 g.

Net carbs calculator. Net carbs = total carbohydrate − fiber − a share of the sugar alcohols (all, half or none). "Net carbs" is not defined on a US label (21 CFR 101.9), so the share is the reader's choice. Example: 30 g total, 8 g fiber and 10 g of sugar alcohols, taking off half, is 17 g.

Protein per meal and macro percentages. The protein calculator divides its daily range by 3, 4 and 5 meals and shows about 0.4 g per kg per meal as a reference (Schoenfeld and Aragon, 2018). The macro percentage converter multiplies calories by each percentage and divides by 4, 4 and 9. Example: 2,000 kcal at 30/40/30 is 150 g, 200 g and 67 g.

Body composition tools

These tools take measurements and return a number; none of them labels the number as healthy or not. The examples use the same man (80 kg, 180 cm), with a body fat of 18%, a waist of 85 cm and hips of 95 cm.

Lean body mass. Boer (1984): 0.407 × weight + 0.267 × height − 19.2 for men, 0.252 × weight + 0.473 × height − 48.3 for women. Hume (1966): 0.3281 × weight + 0.33929 × height − 29.5336 for men, 0.29569 × weight + 0.41813 × height − 43.2933 for women. Weight in kg and height in cm. From a body fat percentage: weight × (1 − body fat ÷ 100). Example: Boer 61.4 kg, Hume 57.8 kg, from 18% body fat 65.6 kg.

FFMI. Fat-free mass ÷ height², and the normalized value FFMI + 6.3 × (1.8 − height in m), from Kouri and colleagues (1995). The abstract gives 6.3; some sites print 6.1. Example: fat-free mass 65.6 kg, FFMI 20.2, normalized 20.2.

Waist ratios. Waist ÷ height and waist ÷ hips, in one unit. Example: 0.47 and 0.89. No cut-off is applied to either.

Body fat from BMI. Deurenberg, Weststrate and Seidell (1991), adults: 1.2 × BMI + 0.23 × age − 10.8 × sex − 5.4, sex 1 for men and 0 for women. Example at BMI 24.7: 20.3%.

Steps tools

Steps to distance. Distance = steps × step length. The step length is typed, or, left blank, estimated from height as 0.415 × height for a man and 0.413 × height for a woman, the rule of thumb step counters have long used. We found no published study that sets those factors, so the pages call the result an estimate and suggest measuring your own step. Example: 10,000 steps at 178 cm gives a step of 73.9 cm and 7.39 km.

Steps to calories. Time = distance ÷ the walking speed the reader picks, and calories = MET × body weight in kg × hours, with the MET of the 2024 Adult Compendium of Physical Activities walking band that holds the speed (the same codes as the walking page of the calories burned calculator). The result is gross, so it includes the energy spent at rest; the page also shows it with 1 MET taken off. Example, 75 kg at 3 mph (3.8 METs): about 92 minutes and 436 kcal. The cadence the pace implies is shown beside the 100 steps a minute that Tudor-Locke and colleagues (2019) proposed for moderate walking.

Hydration tools

Water by body weight. The pages for each weight use the water formula above unchanged, and compare the result with the Institute of Medicine's Adequate Intake of total water (2005).

Sweat loss. Sweat loss = weight before − weight after + fluid drunk − urine passed, with 1 kg counted as 1 litre, divided by the hours to give a rate. This is the weighing method described in the American College of Sports Medicine position stand (Sawka and colleagues, 2007), which also names a loss of more than 2% of body weight as the point to prevent; the calculator shows a note past it. It gives no advice on what to drink or on electrolytes, which the same stand says vary widely between people.

Food maths tools

Recipe calories. The total is the sum, over the ingredients, of each USDA FoodData Central value per 100 g times the grams ÷ 100. Per serving is the total ÷ the servings, and per 100 g is the total ÷ the weight of the ingredients × 100. There is no AI and no estimate in it.

Alcohol calories. Grams of alcohol = volume in ml × ABV ÷ 100 × 0.789, calories = alcohol × 7 kcal per gram + carbohydrate × 4 (the Atwater factors of USDA Agriculture Handbook No. 74). Example: a 355 ml beer at 5% has 14 g of alcohol and 148 kcal.

Caffeine. The sum of servings × the milligrams in one serving, from the USDA value per 100 g and the serving's grams, against the 400 mg a day the FDA and EFSA give for healthy adults.

Sugar intake. Share of energy = grams of free sugars × 4 ÷ daily calories × 100, shown beside the World Health Organization's 10% and 5% lines.

kJ and kcal. kJ = kcal × 4.184, the definition of the thermochemical calorie.

Calories to fat. Kilograms of fat = calories ÷ 7,700 (and pounds = calories ÷ 3,500), the rule of thumb described above, with its limits. Example: 15,400 kcal is 2 kg.

App estimates: photo, voice and text logging

When you photograph or describe a meal in the CalorTracker app, the numbers are estimates, and the app shows them to you to review and correct before they are saved. Here is what happens, at a high level:

  1. An AI model (Google's Gemini) looks at your photo or reads your words and lists the foods it sees, with a guessed weight and a guessed calories-and-macros figure for each.
  2. For each food, the app searches USDA FoodData Central and Open Food Facts by name and gathers candidate matches, which are per-100 g values.
  3. The AI model is then asked to pick the best candidate for each food, or to reject all of them. If it picks one, the app scales that record's per-100 g values by the guessed weight.
  4. When it picks none, the AI's own estimate stands, whether the model rejected every candidate or gave no answer. This is the same for a photo, a voice note and a typed meal.
  5. The totals are the sum over foods, and each line records where its numbers came from.

The weight in step 1 is a guess from a picture, and the match in step 3 or 4 can be the wrong kind of food, so photo logging has real error. We wrote up where it is reliable and where it is not in how accurate is AI calorie counting. Items read off a nutrition label or recalled from your own earlier log are not looked up again.

The same Mifflin-St Jeor, activity-multiplier and 7,700 kcal per kg arithmetic sets the daily calorie target the app proposes during onboarding. The protein and water it proposes count body weight in full only up to a BMI of 30 and 25, and water stays between 1,500 and 4,000 ml, for the same reason as above.

What these numbers are not

Food values are averages for a food as USDA describes it; a particular apple or brand varies. Calculators estimate an average person; your actual needs can differ by hundreds of calories. None of this is medical advice, and anyone who is pregnant, under 18 or managing a health condition should ask a doctor or registered dietitian before changing how they eat. To report a wrong number, write to support@calortracker.com.