# Unit Price Comparison Calculator

> Divides each price by its quantity to get the price per unit, tells which of two options is cheaper per unit and by what percentage.

- Calculator id: `unit-price` · Category: Everyday Life (`everyday`) · Tool name: `calculate_unit_price`
- Canonical page: https://tttkmbb.com/everyday/unit-price · This document: https://tttkmbb.com/everyday/unit-price.md · JSON definition: https://tttkmbb.com/everyday/unit-price.json

## Purpose

Divides each price by its quantity to get the price per unit, tells which of two options is cheaper per unit and by what percentage.

**Use when:** You are comparing two package sizes or brands of the same product (e.g. 500 g for 3.49 vs 1 kg for 5.99) and want the better value per unit.

**Do not use when:** The two quantities are in different units (convert them to the same unit first, e.g. with mass or volume), or you need a discount on a single price (use discount).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `price_a` | number |  | required | Total price of option A. (min 0, max 100000000) |
| `quantity_a` | number |  | required | Quantity in option A (grams, kilograms, litres, pieces …). (> 0, max 1000000000) |
| `price_b` | number |  | required | Total price of option B. (min 0, max 100000000) |
| `quantity_b` | number |  | required | Quantity in option B, in the same unit as quantity_a. (> 0, max 1000000000) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `unit_price_a` | number |  | price_a / quantity_a, per one unit of quantity. |
| `unit_price_b` | number |  | price_b / quantity_b. |
| `cheaper_option` | string |  | 'Option A', 'Option B' or 'Same unit price'. |
| `savings_percent` | number | % | How much lower the cheaper unit price is, relative to the more expensive one. |
| `unit_price_difference` | number |  | \|unit_price_a − unit_price_b\|. |

## Formula

`unit_price = price / quantity; savings_percent = (max(unit_price_a, unit_price_b) − min(unit_price_a, unit_price_b)) / max(unit_price_a, unit_price_b) × 100`

## Data Sources

- Unit price (Wikipedia) — https://en.wikipedia.org/wiki/Unit_price (reference, retrieved 2026-09-23)
- EU Directive 98/6/EC on the indication of unit prices — https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:31998L0006 (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/unit-price?price_a=…&quantity_a=…&price_b=…&quantity_b=…`
- `POST https://tttkmbb.com/api/v1/calculate/unit-price` 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/unit-price · OpenAPI operationId `calculate_unit_price` 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": "unit-price", "inputs": {…}}`

## Example

- 0.5 kg for 3.49 vs 1 kg for 5.99: inputs `{"price_a":3.49,"quantity_a":0.5,"price_b":5.99,"quantity_b":1}` → `{"unit_price_a":6.98,"unit_price_b":5.99,"cheaper_option":"Option B","savings_percent":14.18,"unit_price_difference":0.99}`
- 12 eggs for 2.00 vs 18 eggs for 3.30: inputs `{"price_a":2,"quantity_a":12,"price_b":3.3,"quantity_b":18}` → `{"unit_price_a":0.1667,"unit_price_b":0.1833,"cheaper_option":"Option A","savings_percent":9.09,"unit_price_difference":0.0167}`

```
GET https://tttkmbb.com/api/v1/calculate/unit-price?price_a=3.49&quantity_a=0.5&price_b=5.99&quantity_b=1
```

## Limitations

The two quantities are in different units (convert them to the same unit first, e.g. with mass or volume), or you need a discount on a single price (use discount). All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Which unit should I use for the quantities?**

Any unit, as long as both options use the same one; unit prices are then per that unit. Using kg or L instead of g or ml gives more readable unit prices.

**Is the larger package always cheaper per unit?**

No. Promotions on small sizes frequently undercut bulk packs, which is exactly what this comparison reveals.

## Related

- [Discount Calculator](https://tttkmbb.com/finance/discount.md) — Apply a percentage discount to a price.
- [Percentage Change Calculator](https://tttkmbb.com/math/percentage-change.md) — Percentage difference between two prices.
