# Margin and Markup Calculator

> Computes profit, gross margin percentage and markup percentage from a unit cost and a selling price, or derives the selling price from cost plus a target margin or markup.

- Calculator id: `margin-markup` · Category: Finance (`finance`) · Tool name: `calculate_margin_markup`
- Canonical page: https://tttkmbb.com/finance/margin-markup · This document: https://tttkmbb.com/finance/margin-markup.md · JSON definition: https://tttkmbb.com/finance/margin-markup.json

## Purpose

Computes profit, gross margin percentage and markup percentage from a unit cost and a selling price, or derives the selling price from cost plus a target margin or markup.

**Use when:** You are pricing a product or service and need to convert between cost, price, margin (profit as % of price) and markup (profit as % of cost).

**Do not use when:** You need the sales volume that covers fixed costs (use break-even) or the tax on the price (use sales-tax / vat).

## Input

| Parameter | Type | Unit | Required | Description |
| --- | --- | --- | --- | --- |
| `cost` | number |  | required | Cost of goods or unit cost. (> 0, max 1000000000000) |
| `price` | number |  | optional | Selling price. Give price, margin_percent or markup_percent (in that order of precedence). (min 0, max 1000000000000) |
| `margin_percent` | number | % | optional | Desired gross margin as percent of price; used when price is omitted. (min -1000) |
| `markup_percent` | number | % | optional | Desired markup as percent of cost; used when price and margin_percent are omitted. (min -100, max 100000) |

## Output

| Field | Type | Unit | Description |
| --- | --- | --- | --- |
| `price` | number |  | Given or derived selling price. |
| `profit` | number |  | price − cost. |
| `margin_percent` | number | % | profit / price × 100. |
| `markup_percent` | number | % | profit / cost × 100. |
| `solved_from` | string |  | Which input determined the price: price, margin_percent or markup_percent. |

## Formula

`profit = price − cost; margin_percent = profit / price × 100; markup_percent = profit / cost × 100; price from margin = cost / (1 − margin_percent/100); price from markup = cost × (1 + markup_percent/100)`

Margin and markup describe the same profit relative to different bases (price vs cost), so markup is always the larger number: margin = markup / (1 + markup) and markup = margin / (1 − margin) in fractional form.

## Data Sources

- Investopedia – Profit Margin vs. Markup: What's the Difference? — https://www.investopedia.com/ask/answers/102714/whats-difference-between-profit-margin-and-markup.asp (reference, retrieved 2026-09-23)
- Wikipedia – Gross margin — https://en.wikipedia.org/wiki/Gross_margin (reference, retrieved 2026-09-23)
- Wikipedia – Markup (business) — https://en.wikipedia.org/wiki/Markup_(business) (reference, 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/margin-markup?cost=…`
- `POST https://tttkmbb.com/api/v1/calculate/margin-markup` 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/margin-markup · OpenAPI operationId `calculate_margin_markup` 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": "margin-markup", "inputs": {…}}`

## Example

- Cost 50, price 80: inputs `{"cost":50,"price":80}` → `{"price":80,"profit":30,"margin_percent":37.5,"markup_percent":60,"solved_from":"price"}`
- Cost 40, target margin 25 %: inputs `{"cost":40,"margin_percent":25}` → `{"price":53.33,"profit":13.33,"margin_percent":25,"markup_percent":33.33,"solved_from":"margin_percent"}`

```
GET https://tttkmbb.com/api/v1/calculate/margin-markup?cost=50&price=80
```

## Limitations

You need the sales volume that covers fixed costs (use break-even) or the tax on the price (use sales-tax / vat). Margin and markup describe the same profit relative to different bases (price vs cost), so markup is always the larger number: margin = markup / (1 + markup) and markup = margin / (1 − margin) in fractional form. All values are computed from the formula above; no measurement or live data is involved.

## FAQ

**Why is a 50 % markup only a 33.3 % margin?**

Markup is measured on cost, margin on price. Cost 100 with 50 % markup sells for 150; the 50 profit is 33.3 % of the 150 price.

**Can margin be 100 %?**

No: a 100 % margin would require zero cost, so margin_percent must be below 100. Markup has no upper limit.

## Related

- [Break-Even Calculator](https://tttkmbb.com/finance/break-even.md) — Units needed to cover fixed costs at this contribution margin.
- [VAT Calculator](https://tttkmbb.com/finance/vat.md) — Add VAT on top of the net selling price.
- [Discount Calculator](https://tttkmbb.com/finance/discount.md) — Effect of a discount on the selling price.
