# Margin and markup calculator

Turn a unit cost and selling price into gross profit, gross margin and markup — or find the price that hits a target margin or markup, rounded up to the smallest unit of your currency.

Runs entirely in your browser. Nothing you enter is stored, sent or put in the URL.

[Open the calculator](https://beancount.io/tools/margin-markup-calculator#converter) [Margin vs. markup](https://beancount.io/tools/margin-markup-calculator#definitions)

## Your numbers

What do you want to work out?

You know what one unit costs you and what you charge for it.

You know the cost and the share of the selling price you want to keep as gross profit.

You know the cost and the percentage you want to add on top of it.

Three-letter code such as USD, EUR or JPY. It sets how many decimal places amounts may have and where prices are rounded.

What one unit costs you to buy or make — direct costs only, not rent or salaries.

What the customer pays for one unit, before sales tax.

## Results

Still needed: Unit cost and Selling price.

### Download this result

Complete every field without errors to download a summary. Unfinished calculations are never exported.

## Margin vs. markup: same profit, different base

Both percentages start from the same gross profit. Margin divides it by the selling price; markup divides it by the cost. A product that costs 80 and sells for 100 earns 20 — a 20% margin and a 25% markup.

### Gross margin

gross margin = (price − cost) ÷ price

The share of every sale you keep after paying for what you sold. It can never reach 100%, because that would mean the item cost nothing.

### Markup

markup = (price − cost) ÷ cost

How much you add on top of cost. It has no ceiling: doubling the cost is a 100% markup but only a 50% margin.

To convert: markup = margin ÷ (1 − margin), and margin = markup ÷ (1 + markup).

This calculator covers one product's gross pricing. It does not judge whether a margin is good for your industry. [Read the markup-versus-margin guide](https://beancount.io/blog/2026/05/18/markup-versus-margin-pricing-math-small-businesses-get-wrong-convert-between-why-50-percent-markup-not-50-percent-margin-guide)

## Margin and markup questions

**What is the difference between margin and markup?**

Both use the same gross profit (price minus cost). Gross margin divides it by the selling price; markup divides it by the cost. Cost 80 and price 100 give a 20% margin and a 25% markup.

**Why is markup always higher than margin?**

For a profitable sale the cost is smaller than the price, so the same profit is a larger share of the cost. That is why a 50% markup is only about a 33% margin.

**Why can a target margin not be 100%?**

A 100% margin means the whole price is profit, so the cost would have to be zero. For any positive cost, the price cost ÷ (1 − 100%) would be infinite, so the calculator asks for a target below 100%.

**Is this my net profit margin?**

No. It is gross margin for one unit: only the direct cost of what you sell. Rent, salaries, fees and taxes come out later, in operating and net margin.

**Is anything I type stored or sent?**

No. The calculation runs in your browser, and your numbers are not saved, uploaded or added to the page address. Reloading the page clears them.

## Keep your real margins in your books

Beancount.io records every sale and cost in plain text, so your actual gross margin is a query away instead of a guess.

[Start Free→](https://beancount.io/sign-up/?next=%2Fledger%2F) [Markup vs. margin guide](https://beancount.io/blog/2026/05/18/markup-versus-margin-pricing-math-small-businesses-get-wrong-convert-between-why-50-percent-markup-not-50-percent-margin-guide) [How to calculate profit margin](https://beancount.io/blog/2026/04/10/how-to-calculate-profit-margin-the-complete-guide-for-small-business-owners)

## Where to look next

- [Sitemap](https://beancount.io/sitemap.xml) - all pages with hreflang alternates
- [LLMs index](https://beancount.io/llms.txt) - curated links for AI agents (also /llms-full.txt for full docs)
- [Documentation](https://beancount.io/docs) - every doc is also available as text/markdown via .md suffix or Accept negotiation
- [REST API reference](https://beancount.io/docs/api-reference) - interactive endpoints, schemas, authentication, and code samples
- [OpenAPI spec](https://beancount.io/openapi.json) - OpenAPI 3.1 spec for this website's public content endpoints; the product contract for ledger operations is at https://beancount.io/api-gateway/v1/openapi.json
- [GraphQL](https://beancount.io/graphql) - public, read-only content API over the blog and research logs (no credentials, no ledger data): 12 query fields over 23 types
- [MCP server](https://beancount.io/mcp) - Model Context Protocol at https://beancount.io/api-gateway/mcp
