Skip to content

Margin Calculator (Gross Profit Margin and Price for a Target Margin)

Gross profit margin from cost and selling price, or the price that gives a target margin — with the markup that margin equals and the working.

Inputs

Example: Gross margin
40.00%

Use this calculator on your own site

Free embed

  • Two lines of HTML, unlimited views
  • Shows a small CalculateEveryday bar, with a credit link under the calculator

What each Margin input means

Work out
Margin from a known cost and price, or the price that hits a margin you choose.
Cost
What one item costs you to buy or make — the cost of goods sold per unit. Leave out overheads such as rent; those come out of gross profit later.
Selling price
The selling price, before sales tax.
Target gross margin
The gross margin you want, as a share of the price. Must be below 100%.

Margin formula

Gross margin = (price − cost) ÷ price · price for a target margin = cost ÷ (1 − margin) · markup = (price − cost) ÷ cost

m=p−cpp=c1−mm = \frac{p - c}{p} \qquad p = \frac{c}{1 - m}

Gross margin is profit as a share of the selling price: what is left of each sale after the cost of the goods, divided by the price. Accountants write it as the gross profit margin ratio, (net sales − cost of goods sold) ÷ net sales, which is the same thing for a whole business. It is easy to confuse with markup, which divides the same profit by the cost instead, so a 40% margin is a 66.67% markup; the page always shows both. Run the other way, the page answers the question pricing usually starts from: what price gives the margin I want? Because margin is measured on the price, you cannot simply add the margin percentage to the cost — the price is the cost divided by (1 − margin), so a 40% margin on a 45 cost needs a price of 75, not 63. A margin can never reach 100%, which would need a cost of zero, and a price below cost gives a negative margin, which the page flags as a loss on every sale before any overheads.

Formula last checked against OpenStax Principles of Accounting, Vol. 1 §6.6 (gross profit margin ratio = (net sales − cost of goods sold) ÷ net sales) on 2 October 2026. Built and maintained by Suman Kumar · How we check

Margin worked example

An item that costs $60 and sells for $100 leaves $40. That is a 40% margin (40 ÷ 100) but a 66.67% markup (40 ÷ 60) — the same profit, two different percentages.

More Margin examples

To earn a 40% margin on something that costs 45, the price is 45 ÷ (1 − 0.40) = 45 ÷ 0.60 = 75.00. The profit of 30.00 is 40% of the price — and a 66.67% markup on the cost. Adding 40% to the cost would give only 63, a 28.57% margin.

Where the Margin calculator can give the wrong answer

  • This is gross margin, before operating costs. Net margin subtracts rent, wages, marketing and tax as well, and is always lower.
  • Margin is capped below 100%; a 100% margin would mean the item cost nothing.
  • Discounts come off the price, so they cut margin faster than they cut revenue: a 20% discount on an item with a 40% margin halves the profit per sale.
  • Sales tax collected for the government is not revenue; enter prices before tax.
  • Results are shown to two decimal places in whatever currency you are working in; the page applies no currency symbol.

Spotted a mistake? Tell us

Margin reference table

Margin and the markup it equals
Gross marginMarkup on costPrice for a cost of 100
10%11.11%111.11
20%25.00%125.00
25%33.33%133.33
33.33%50.00%150.00
40%66.67%166.67
50%100.00%200.00
60%150.00%250.00
Source: Markup = margin ÷ (1 − margin); price = cost ÷ (1 − margin)

Margin FAQ

Subtract the cost from the price and divide by the price. Cost 30, price 50: (50 − 30) ÷ 50 = 0.40, a 40% gross margin. For a whole business, use total sales and total cost of goods sold.