Home › Finance › Margin and Markup Calculator
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.
When to use
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).
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.
Inputs
| Parameter | Type | Unit | Required | Description |
|---|---|---|---|---|
cost | number | yes | Cost of goods or unit cost. Range: > 0, ≤ 1000000000000 | |
price | number | no | Selling price. Give price, margin_percent or markup_percent (in that order of precedence). Range: ≥ 0, ≤ 1000000000000 | |
margin_percent | number | % | no | Desired gross margin as percent of price; used when price is omitted. Range: ≥ -1000 |
markup_percent | number | % | no | Desired markup as percent of cost; used when price and margin_percent are omitted. Range: ≥ -100, ≤ 100000 |
Outputs
| Output | 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. |
Example
Cost 50, price 80: {"cost":50,"price":80} → {"price":80,"profit":30,"margin_percent":37.5,"markup_percent":60,"solved_from":"price"}
Cost 40, target margin 25 %: {"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
Machine access
- API:
GET https://tttkmbb.com/api/v1/calculate/margin-markup(query parameters) orPOSTwith a JSON body{"inputs": {...}} - Schema: https://tttkmbb.com/api/v1/calculators/margin-markup · Markdown: https://tttkmbb.com/finance/margin-markup.md · JSON definition: https://tttkmbb.com/finance/margin-markup.json
- MCP: server
https://tttkmbb.com/mcp, toolrun_calculator with calculator_id="margin-markup" - OpenAPI operationId:
calculate_margin_markup - Freshness:
static. Authentication: none. Rate limit: fair use (see rate limits).
Sources
- Investopedia – Profit Margin vs. Markup: What's the Difference? (reference)
- Wikipedia – Gross margin (reference)
- Wikipedia – Markup (business) (reference)
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 calculators
- Break-Even Calculator — Units needed to cover fixed costs at this contribution margin.
- VAT Calculator — Add VAT on top of the net selling price.
- Discount Calculator — Effect of a discount on the selling price.