Margin Calculator
This margin calculator finds the profit, the gross margin and the markup from a cost and a selling price. It also works backwards: give it a cost and a target margin to get the price to charge, or a price and a target margin to get the most you can pay. A bar shows how much of the price is cost and how much is profit, with the formulas and steps underneath.
How to use the margin calculator
- Pick a mode. Cost & price is the default.
- Enter the two numbers that mode asks for, and change the currency symbol if you need to.
- Read the margin, markup and profit at the top, and the formulas and steps below the bar.
The defaults are a cost of $40 and a price of $65. The profit is $65 − $40 = $25, the margin is $25 ÷ $65 ≈ 38.46% and the markup is $25 ÷ $40 = 62.5%. Same $25 of profit, two different percentages, because margin measures profit against the price and markup measures it against the cost.
The other two modes solve for the missing number:
- Cost & margin gives the price. A $40 cost at a 35% margin needs a price of about
$61.54. - Price & margin gives the cost. A $65 price at a 35% margin allows a cost of
$42.25.
The stacked bar is the price split into its two parts. The profit segment’s share of the whole bar is the margin. If you want the other relationship in more detail, the full comparison is in the guide to margin vs markup, and the markup calculator solves the same problem starting from a markup percentage.
The margin formulas
The first two formulas are both ordinary “what percent of” questions with the same top number, the profit, over two different bottoms. That is the whole difference between margin and markup, and it is why the what percent of calculator would give you either one if you fed it the right base.
The third pair comes from a simple observation. If the margin is 35%, then profit is 35% of the price, so cost must be the other 65%. That gives cost = price × 0.65 directly, which is an ordinary “65% of $65” question for the percentage calculator. Turning it around, price = cost ÷ 0.65. Dividing by 1 − margin is a reverse percentage: you know the cost is a fixed share of a price you have not found yet.
Worked examples
Example: cost and price known
A shop buys an item for $18 and sells it for $45.
A 150% markup sounds large, but it is the same deal as a 60% margin. Every $45 sale keeps $27 of gross profit.
Example: pricing to a 60% margin
A product costs $12.50 and you want a 60% gross margin.
Multiplying the cost by 1.6 instead would give $20, which is only a 37.5% margin. That is the most common pricing slip, covered below.
Example: the most you can pay for stock
The market price for an item is $65 and you need a 35% margin on it.
Any supplier price above $42.25 drops the margin under 35%. This is the default “Price & margin” case in the calculator.
Gross margin vs net profit margin
People search for a profit margin calculator and a gross margin calculator as if they were the same tool. The formula is identical; what changes is which costs you subtract.
- Gross margin subtracts only the direct cost of the goods sold: what you paid for the product or to make it.
- Operating margin also subtracts running costs such as rent, wages and marketing.
- Net profit margin subtracts everything, including interest and taxes.
This calculator works on one item at a time with one cost, so it gives the gross margin. For a whole business, put total revenue in the price field and the cost you care about in the cost field:
Both are correct; they answer different questions. Gross margin tells you whether each sale covers what the product costs. Net margin tells you whether the business as a whole keeps any money.
Margin across several products
When you sell more than one product, the overall margin is total profit divided by total revenue. It is not the average of the individual margins.
Product B brings in three times the revenue, so it counts three times as much. The overall figure is a revenue-weighted average, which the weighted average calculator can confirm if you enter the margins as values and the revenues as weights. Averaging the margins directly overstates the result whenever the low-margin products also sell the most.
Price needed for a target margin
The price for any margin is the cost divided by 1 − margin, which is the same as multiplying the cost by a fixed factor. Here are those factors, applied to the default $40 cost. Repeating decimals are rounded.
| Target margin | Divide cost by | Same as multiplying by | Price for a $40 cost |
|---|---|---|---|
| 20% | 0.80 | 1.25 | $50.00 |
| 25% | 0.75 | ≈ 1.3333 | ≈ $53.33 |
| 30% | 0.70 | ≈ 1.4286 | ≈ $57.14 |
| 35% | 0.65 | ≈ 1.5385 | ≈ $61.54 |
| 40% | 0.60 | ≈ 1.6667 | ≈ $66.67 |
| 50% | 0.50 | 2 | $80.00 |
| 60% | 0.40 | 2.5 | $100.00 |
The multiplier grows faster as the margin climbs. Going from 20% to 30% raises the price factor by about 0.18; going from 50% to 60% raises it by 0.5. Each extra point of margin gets more expensive to reach.
Negative margins and the 100% ceiling
Selling below cost gives a negative margin. A $40 item sold for $35 loses $5. The margin is −$5 ÷ $35 ≈ −14.29% and the markup is −$5 ÷ $40 = −12.5%. Clearance pricing and loss leaders show up this way, and the calculator reports the loss with a minus sign rather than an error.
Margin can never reach 100%. A 100% margin would mean the entire price is profit, which only happens if the cost is zero. As the margin target approaches 100%, 1 − margin approaches zero and the required price grows without limit. Markup has no such ceiling: a 300% or 500% markup is possible, and corresponds to a 75% or about 83.33% margin.
A zero price makes margin undefined, since you cannot divide by zero. A zero cost makes markup undefined for the same reason, while the margin is simply 100%.
Common mistakes
- Multiplying the cost by 1 + margin. A $40 cost × 1.35 gives $54, which is a margin of only about 25.93%. To get 35% you need
$40 ÷ 0.65 ≈ $61.54. - Calling a markup a margin. A 62.5% markup and a 38.46% margin describe the same $40-to-$65 sale. Say which one you mean, especially when comparing with a supplier or an industry figure.
- Averaging margins across products. Divide total profit by total revenue instead.
- Leaving costs out. Shipping, packaging and payment fees that you pay on every sale belong in the cost if you want a realistic gross margin.
- Counting sales tax as revenue. Tax collected at the register is passed on, not kept. Use the pre-tax price; the sales tax calculator strips tax out of a tax-inclusive total.
- Reading a margin change as a percentage change. A margin moving from 30% to 35% is up 5 percentage points, which is a percentage change of about 16.67%.
Frequently asked questions
How do you calculate profit margin?
Subtract the cost from the price to get the profit, divide the profit by the price, and multiply by 100. For a $40 cost and a $65 price, the profit is $25 and the margin is $25 ÷ $65 × 100 ≈ 38.46%. Always divide by the price, not the cost; dividing by the cost gives the markup instead.
What is the difference between margin and markup?
Both use the same profit, but margin divides it by the selling price and markup divides it by the cost. A $40 item sold for $65 has a $25 profit, a 38.46% margin and a 62.5% markup. Margin is always the smaller number when there is a profit, and it can never reach 100%.
How do I price something for a 35% margin?
Divide the cost by 1 − 0.35 = 0.65. For a $40 cost, the price is $40 ÷ 0.65 ≈ $61.54, which leaves about $21.54 of profit, 35% of the price. Multiplying the cost by 1.35 is a common mistake that only gives $54 and a margin of about 25.93%.
What is a 50% margin as a markup?
A 50% margin equals a 100% markup. If the cost is $40, a 50% margin means a price of $80: the $40 profit is half of the $80 price and all of the $40 cost. Doubling the cost to set the price is sometimes called keystone pricing.
Is gross margin the same as profit margin?
Gross margin is one kind of profit margin. It only subtracts the direct cost of the goods. Net profit margin subtracts every expense, including rent, wages, interest and tax. A business with $200,000 revenue and $120,000 cost of goods has a 40% gross margin; with another $50,000 of expenses, its net margin is 15%.
Can a profit margin be over 100%?
No. Margin is profit as a share of the price, and profit cannot be larger than the price unless the cost is negative. The maximum is 100%, reached only at zero cost. Markup has no upper limit: a $10 item sold for $50 has a 400% markup but an 80% margin.
How do you calculate the cost from the price and margin?
Multiply the price by 1 − margin. For a $65 price and a 35% margin, the cost is $65 × 0.65 = $42.25, leaving $22.75 of profit. This tells you the most you can pay a supplier while still meeting your margin target.
Related calculators
Guides that use this calculator
Longer explanations of the method behind it, with worked examples.
Put this calculator on your own site (free)
Copy this into any page. The calculator stays up to date on its own, works on mobile, and carries a small credit link back here.
https://fourfunctioncalculator.com/margin-calculator/