# Calories from Macros Calculator

> Converts grams of protein, carbohydrate, fat and alcohol into kilocalories and kilojoules with the Atwater general factors (4 / 4 / 9 / 7 kcal per gram) and reports each macronutrient's share of total energy.

- Calculator id: `calories-from-macros` · Category: Food & Cooking (`food`) · Tool name: `calculate_calories_from_macros`
- Canonical page: https://tttkmbb.com/food/calories-from-macros · This document: https://tttkmbb.com/food/calories-from-macros.md · JSON definition: https://tttkmbb.com/food/calories-from-macros.json

## Purpose

Converts grams of protein, carbohydrate, fat and alcohol into kilocalories and kilojoules with the Atwater general factors (4 / 4 / 9 / 7 kcal per gram) and reports each macronutrient's share of total energy.

**Use when:** You have the macronutrient grams of a food, meal or daily intake and need total calories or the percentage split, e.g. to check a food label or diet plan.

**Do not use when:** You want to go the other way, from a calorie target to gram targets (use macros), or need calorie needs (use tdee).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `protein_g` | number | g | required | Protein in grams. (min 0, max 5000) |
| `carbs_g` | number | g | required | Total carbohydrate in grams, including any fibre. (min 0, max 5000) |
| `fat_g` | number | g | required | Fat in grams. (min 0, max 5000) |
| `alcohol_g` | number | g | optional, default 0 | Ethanol in grams (a 330 ml 5 % beer contains about 13 g). (min 0, max 1000) |
| `fiber_g` | number | g | optional | Optional fibre included in carbs_g; counted at 2 kcal/g (EU labelling factor) instead of 4 kcal/g. (min 0, max 1000) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `calories_kcal` | number | kcal | Sum of all macronutrient energy. |
| `energy_kj` | number | kJ | Total energy in kilojoules (× 4.184). |
| `protein_kcal` | number | kcal | protein_g × 4. |
| `carbs_kcal` | number | kcal | (carbs_g − fiber_g) × 4 + fiber_g × 2. |
| `fat_kcal` | number | kcal | fat_g × 9. |
| `alcohol_kcal` | number | kcal | alcohol_g × 7. |
| `protein_percent` | number | % | Protein energy as a percentage of total energy. |
| `carbs_percent` | number | % | Carbohydrate energy as a percentage of total energy. |
| `fat_percent` | number | % | Fat energy as a percentage of total energy. |
| `alcohol_percent` | number | % | Alcohol energy as a percentage of total energy. |

## Formula

`kcal = 4·protein_g + 4·(carbs_g − fiber_g) + 2·fiber_g + 9·fat_g + 7·alcohol_g; percent_x = kcal_x / kcal × 100; kJ = kcal × 4.184`

Atwater general factors are averages of metabolisable energy; label values can differ by a few percent because manufacturers may use specific factors, and US labels may count insoluble fibre at 0 kcal/g.

## Data Sources

- FAO (2003) Food energy – methods of analysis and conversion factors (Atwater general factors) — https://www.fao.org/4/y5022e/y5022e00.htm (standard, retrieved 2026-09-23)
- Regulation (EU) No 1169/2011 Annex XIV – energy conversion factors (fibre 2 kcal/g, alcohol 7 kcal/g) — https://eur-lex.europa.eu/eli/reg/2011/1169/oj (standard, retrieved 2026-09-23)

Data freshness: `static`. Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output.

## API

- `GET https://tttkmbb.com/api/v1/calculate/calories-from-macros?protein_g=…&carbs_g=…&fat_g=…`
- `POST https://tttkmbb.com/api/v1/calculate/calories-from-macros` with JSON body `{"inputs": {…}}`
- Response: unified envelope (`success`, `request`, `result.values`, `result.units`, `sources`, `freshness`, `timestamp`, `next_actions`, `links`); see https://tttkmbb.com/docs/response-format.md
- Schema: https://tttkmbb.com/api/v1/calculators/calories-from-macros · OpenAPI operationId `calculate_calories_from_macros` in https://tttkmbb.com/openapi.json
- Authentication: none. Rate limit: fair use, see https://tttkmbb.com/docs/rate-limits.md.

## MCP

- Server: `https://tttkmbb.com/mcp` (Streamable HTTP, JSON-RPC 2.0, no auth)
- Tool:  `run_calculator` with `{"calculator_id": "calories-from-macros", "inputs": {…}}`

## Example

- 30 g protein, 40 g carbs, 10 g fat: inputs `{"protein_g":30,"carbs_g":40,"fat_g":10}` → `{"calories_kcal":370,"energy_kj":1548,"protein_kcal":120,"carbs_kcal":160,"fat_kcal":90,"protein_percent":32.4,"carbs_percent":43.2,"fat_percent":24.3,"alcohol_percent":0}`
- 25 / 50 / 15 g plus 14 g alcohol: inputs `{"protein_g":25,"carbs_g":50,"fat_g":15,"alcohol_g":14}` → `{"calories_kcal":533,"alcohol_kcal":98,"alcohol_percent":18.4,"carbs_percent":37.5}`

```
GET https://tttkmbb.com/api/v1/calculate/calories-from-macros?protein_g=30&carbs_g=40&fat_g=10
```

## Limitations

You want to go the other way, from a calorie target to gram targets (use macros), or need calorie needs (use tdee). Atwater general factors are averages of metabolisable energy; label values can differ by a few percent because manufacturers may use specific factors, and US labels may count insoluble fibre at 0 kcal/g. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why does the label show fewer calories than this?**

Labels may subtract insoluble fibre entirely (US) or use specific Atwater factors for the food; rounding rules also allow small differences.

**Does 'net carbs' apply here?**

Only via fiber_g: fibre is counted at 2 kcal/g. Sugar alcohols are not handled separately (they average about 2.4 kcal/g).

## Related

- [Macro Calculator](https://tttkmbb.com/health/macros.md) — Reverse direction: grams of each macro from a calorie target.
- [TDEE Calculator](https://tttkmbb.com/health/tdee.md) — Compare the intake with daily energy needs.
