Nutrients and units

Every nutrient and its integer unit: energy in millikilocalories, macros and most minerals in milligrams, some vitamins in micrograms.

Every amount in the database and in op results is an integer in its nutrient's base unit, never a float, so sums stay exact and rounding happens once, for display. A missing key means unknown, not zero. Results also carry totals_display in kcal and grams for people.

  • Energy in millikilocalories (mkcal): 1 kcal = 1,000 mkcal.
  • Macros and most minerals in milligrams (mg): 1 g = 1,000 mg.
  • Vitamins labels give in µg (A, D, B12, folate) in micrograms (ug).
One egg, stored → displayed
{  "energy": 143000,  "protein": 12560,  "fat": 9510,  "sodium": 142,  "vitamin_d": 2}
{  "energy": {    "value": 143,    "unit": "kcal"  },  "protein": {    "value": 12.6,    "unit": "g"  },  "fat": {    "value": 9.5,    "unit": "g"  },  "sodium": {    "value": 142,    "unit": "mg"  },  "vitamin_d": {    "value": 2,    "unit": "µg"  }}

Every nutrient

The first panel every meal reply and day total shows is marked core. New nutrients are added as new keys; a key's unit never changes.

KeyStored asCore
energymkcal (millikilocalories)core
proteinmg (milligrams)core
carbsmg (milligrams)core
fatmg (milligrams)core
saturated_fatmg (milligrams)core
trans_fatmg (milligrams)
fibermg (milligrams)core
sugarmg (milligrams)core
added_sugarmg (milligrams)core
sodiummg (milligrams)core
cholesterolmg (milligrams)
potassiummg (milligrams)
calciummg (milligrams)
ironmg (milligrams)
magnesiummg (milligrams)
zincmg (milligrams)
vitamin_cmg (milligrams)
vitamin_aug (micrograms)
vitamin_dug (micrograms)
vitamin_b12ug (micrograms)
folateug (micrograms)
caffeinemg (milligrams)

Converting

  • From a label: kcal × 1,000 → mkcal; g × 1,000 → mg; mg as is; µg as is (mg × 1,000 for a vitamin stored in µg).
  • For display: mkcal ÷ 1,000 → kcal; mg ÷ 1,000 → g for macros; sodium, potassium, calcium, cholesterol, caffeine and magnesium stay in mg.
  • Nutrients from a photo are estimates from the matched food and the portion; a barcoded product uses its label; your edits override both.