Gross Margin Formula: How to Calculate It, With Examples
Short answer: The gross margin formula is (revenue − cost of goods sold) ÷ revenue × 100. It gives the share of each sales dollar left after direct costs. If you sell for $100 and the product cost you $60, gross margin is ($100 − $60) ÷ $100 × 100 = 40%.
To check your own numbers as you read, use our Margin & Markup Calculator. It takes cost, price, margin or markup and shows the working for each result.
What is the formula for gross margin?
Gross margin is gross profit divided by revenue, written as a percentage. Gross Profit Margin = (Revenue - COGS) / Revenue x 100. Gross profit is the dollar amount: revenue minus cost of goods sold (COGS).
Written as two lines:
- Gross profit = Revenue − COGS
- Gross margin (%) = Gross profit ÷ Revenue × 100
A 20% gross profit margin means the business retains 20 cents in gross profit for every dollar of revenue, after direct costs. The margin tells you how efficiently each sales dollar turns into profit before overhead.
How do you calculate gross margin step by step?
- Find revenue. Use the sales figure for the period or for one item. Revenue here means net revenue, not your gross sales total. Take off returns and discounts first.
- Find COGS. Add up the direct costs of the goods you sold, such as materials and the purchase cost of stock.
- Subtract. Revenue − COGS = gross profit.
- Divide. Gross profit ÷ revenue gives a decimal.
- Multiply by 100. This turns the decimal into a percentage.
Worked example: a small online shop
A shop has $8,000 in net sales for the month. The products it sold cost $5,000 to buy.
- Gross profit = $8,000 − $5,000 = $3,000
- Gross margin = $3,000 ÷ $8,000 = 0.375
- 0.375 × 100 = 37.5%
The shop keeps $0.375 of every sales dollar after paying for the goods. Rent, wages and marketing still have to come out of that.
Worked example: a single product
You buy a jacket for $60 and sell it for $100.
- Gross profit = $100 − $60 = $40
- Gross margin = $40 ÷ $100 × 100 = 40%
For ugly decimals, such as a margin of 37.5% or 33.333…%, choose how many places to show. The Rounding Calculator shows each rounding step.
Gross margin vs gross profit: what is the difference?
Gross profit is a dollar amount. Gross margin is a percentage. People often use the two terms interchangeably, but gross profit is an absolute monetary amount and gross margin is a percentage or ratio.
You need both. Gross profit can rise in dollars while the margin percentage stays flat or falls. Selling twice as much at a thinner margin can raise profit and still signal a pricing problem.
Gross margin vs markup: why are they different?
They use the same profit but divide by different numbers. Margin divides by revenue, while markup divides by cost. That is why markup is always the larger percentage when you sell above cost.
Using the jacket: markup = ($100 − $60) ÷ $60 × 100 = 66.7%. Margin = ($100 − $60) ÷ $100 × 100 = 40%. Same $40 profit, two different percentages.
Mixing them up is a common pricing error. A 25% markup produces a gross margin of only 20%.
Markup to margin conversion table
To convert, use these two formulas. Margin = Markup / (1 + Markup), and Markup = Margin / (1 - Margin). The table below applies the first one.
| Markup on cost | Gross margin on price |
|---|---|
| 20% | 16.7% |
| 25% | 20% |
| 33.3% | 25% |
| 50% | 33.3% |
| 75% | 42.9% |
| 100% | 50% |
Example: a 50% markup gives 0.50 ÷ (1 + 0.50) = 0.333, or a 33.3% margin. The values in the table are from Xero's markup-to-margin chart, and each one follows from the formula above.
How do you set a price from a target gross margin?
Do not add the margin percentage to cost. That gives you a markup, and your real margin will come out lower. Divide cost by one minus the margin instead.
Price = Cost ÷ (1 − target margin)
Example: a product costs $100 and you want a 25% margin. The price is $100 ÷ (1 − 0.25) = $133.33, which is a markup of 33.3%.
Check it: $133.33 − $100 = $33.33 profit. $33.33 ÷ $133.33 = 25%.
If you are running a sale, see how a discount cuts into margin with the Discount Calculator. Take the discounted price as your new revenue and recalculate.
How do you find cost or revenue from a known margin?
Rearrange the formula. With a margin as a decimal (40% = 0.40):
- Gross profit = Revenue × margin
- COGS = Revenue × (1 − margin)
- Revenue = COGS ÷ (1 − margin)
Example: revenue is $20,000 and the margin is 60%. Gross profit = $20,000 × 0.60 = $12,000, so COGS = $8,000. The same numbers appear in a Xero example, where $12,000 ÷ $20,000 × 100 = 60%.
For general "what percent of what" questions, the Percentage Calculator covers the basic steps.
Gross margin vs operating margin vs net margin
All three divide a profit figure by revenue. Only the profit figure changes. Gross margin deducts only COGS. Operating margin also deducts operating expenses. Net margin deducts all expenses, including interest and taxes.
| Margin | Profit figure used | What it shows |
|---|---|---|
| Gross margin | Revenue − COGS | Profit after direct costs of the product |
| Operating margin | Revenue − COGS − operating expenses | Profit from running the business |
| Net margin | Revenue − all expenses | What is left after everything |
Gross margin is always the highest of the three. In one published example, $500k of gross profit on $700k of revenue is a 71.4% gross margin, while $100k of net income gives a 14.3% net margin.
What mistakes make gross margin wrong?
- Dividing by cost. That gives markup, not margin.
- Using gross sales instead of net revenue. Returns and discounts should come off first.
- Counting overhead as COGS, or leaving direct costs out. The COGS formula is the same across most industries, but what counts in each element varies. Keep your definition consistent from period to period.
- Entering the margin as 40 instead of 0.40. When you rearrange the formula, convert the percentage to a decimal first.
- Comparing across industries. A good margin for a software firm may be a poor one for a grocer.
What this guide does not cover
This guide covers the standard formula for gross margin used in US business reporting. It does not cover:
- accounting rules for inventory valuation (FIFO, LIFO, average cost)
- which costs a specific tax authority treats as COGS
- industry benchmarks for a "good" margin
Ask an accountant for any of those. Some service businesses report gross margin with labor in COGS, and others do not, so check how your own books define it.
Frequently asked questions
What is the gross margin formula in simple terms?
Subtract your cost of goods sold from revenue to get gross profit. Divide that gross profit by revenue, then multiply by 100. For example, $100 revenue with $60 COGS gives $40 gross profit, and $40 ÷ $100 × 100 is a 40% gross margin.
Is gross margin the same as markup?
No. Both use the same profit, but margin divides it by selling price and markup divides it by cost. A product that costs $60 and sells for $100 has a 40% margin and a 66.7% markup. Markup is always higher when price is above cost.
How do I convert a 50% markup to gross margin?
Divide the markup by one plus the markup. For 50%, that is 0.50 ÷ 1.50 = 0.333, so the gross margin is 33.3%. To go the other way, divide the margin by one minus the margin.
Can gross margin be negative?
Yes. If the cost of goods sold is higher than revenue, gross profit is negative and so is the margin. For example, selling something for $80 that cost $100 gives −$20 ÷ $80 × 100 = −25%.
What is a good gross margin?
It depends on the industry, so there is no single target. A good margin covers your operating costs and leaves a profit. Compare your figure with similar businesses and with your own past periods, not with a general rule.
How do I calculate the selling price for a target gross margin?
Divide your cost by one minus the target margin as a decimal. For a $100 cost and a 25% margin, the price is $100 ÷ 0.75 = $133.33. Adding 25% to cost would give $125, which is only a 20% margin.
Sources
- Profit margin formula: how to calculate your margins (Xero)
- What is gross profit margin? Formula, examples, and tips (Xero)
- Margin vs Markup (Xero)
- Gross Profit Margin: Definition, Formula and Analysis (Fathom)
- Profit Margin - Definition, Formula, Types & Examples (Corporate Finance Institute)
- Markup vs. Margin: What Is the Difference? (Consero Global)
- Gross Margin (Wikipedia)
- Profit margin (Wikipedia)
- Gross Margin (MetricHQ)