Table of Content

Read time

13 minutes

How do you calculate gross margin?

A gross margin calculator applies one formula: revenue minus cost of goods sold, divided by revenue, times 100. A product that sells for $50 and costs $30 has a gross profit of $20 and a gross margin of 40%. Markup on the same sale is 66.7%, because markup divides by cost, not price.

TL;DR

  • Formula: gross margin = (revenue – cost of goods sold) / revenue x 100. Revenue of $50 and a $30 cost is a $20 gross profit and a 40% gross margin.
  • Profit vs margin: gross profit is the dollar amount left after cost of goods sold. Gross margin is that amount as a percent of revenue.
  • Margin vs markup: they use the same profit but divide by different bases. A 40% margin is a 66.7% markup, and a 20% margin needs a 25% markup.
  • Pricing: price for a target margin = cost / (1 – margin). A $42 cost at a 35% margin needs a price of $64.62, not $56.70.
  • Costs: use landed product cost (purchase price, inbound freight, duties, packaging) and net sales after returns and discounts, or the margin will read too high.
  • Benchmark: NYU Stern’s January 2026 data for US public companies puts general retail at 33.18%, apparel at 56.88% and software at 71.72%. Compare within your own industry.
  • Next step: gross margin is the ceiling on what you can spend per order on ads, fees and shipping. If you want margin by product tracked automatically in your store or ERP, our eCommerce development services and Odoo development services teams build that.

Gross margin calculator

Enter your own numbers. The starting values are an example, not a benchmark. Use net selling price (after discounts) and full landed cost per unit.

Your price and cost
Pricing for a target
What you earn now
Gross profit per unit–
Gross margin–
Markup on cost–
Total revenue for the units–
Total gross profit for the units–
What you need for your target margin
Price needed at your cost–
Markup on cost that gives the target–
Highest cost you can pay at your current price–
Enter your numbers above.

A gross margin calculator turns two numbers, what you sell something for and what it costs you, into the share of each sale you keep. This guide gives you the gross margin formula, the steps to work it out by hand, a margin to markup conversion table, and the pricing math that tells you what to charge for a target margin. Every example shows its arithmetic, so you can check any online gross profit margin calculator against it.

The numbers in the examples are illustrations chosen to make the math easy to follow. They are not benchmarks and do not come from any real store. The only industry figures in the article are the dated, sourced ones in the benchmark section.

What is gross margin, and how is it different from gross profit, markup and net margin?

Gross margin is the percentage of revenue left after you pay the direct cost of what you sold. The Corporate Finance Institute describes the ratio, also called the gross profit margin ratio, as the share of each revenue dollar kept as gross profit. Five neighboring terms get mixed up with it, and mixing them up is the most common reason a margin figure is wrong.

Term What it tells you Formula Divided by
Gross profit Dollars left after cost of goods sold Revenue – COGS Not a percent
Gross margin (gross profit margin, GP%) Share of revenue kept after cost of goods sold (Revenue – COGS) / Revenue x 100 Revenue (selling price)
Markup Gross profit as a share of what the item cost you (Revenue – COGS) / COGS x 100 Cost
Contribution margin Share of revenue left after all variable costs, such as payment fees (Revenue – all variable costs) / Revenue x 100 Revenue
Operating margin Share of revenue left after operating expenses, before interest and taxes Operating profit / Revenue x 100 Revenue
Net margin Share of revenue left after every expense, including interest and taxes Net profit / Revenue x 100 Revenue

Xero draws the line between the first three clearly: margin shows gross profit as a percentage of revenue, while markup shows the same gross profit as a percentage of costs, according to Xero’s margin calculator page. Shopify’s gross margin guide gives the definitions for contribution, operating and net margin. Wikipedia’s gross margin entry adds one useful note, that gross profit is an amount of money and gross margin is a percentage, even though people often use the two words as if they were the same.

What is the gross margin formula behind every gross margin calculator?

The gross margin formula has two steps, and a gross margin calculator runs both:

Gross profit = revenue – cost of goods sold

Gross margin (%) = gross profit / revenue x 100

Revenue here should be net sales: gross sales minus returns, allowances and discounts, which is how Shopify’s gross margin guide defines the input. If you refunded $2,000 of last month’s orders, those dollars are not revenue you kept, so they come out before you divide. The result can never reach 100% unless the goods cost nothing, and it turns negative when cost is higher than price.

Cost of goods sold, usually shortened to COGS, is the direct cost of the products you sold in the period. The IRS treats gross profit as the figure you find before any business expenses are deducted, which is why rent, salaries and marketing never belong in it, as IRS Publication 334, Tax Guide for Small Business explains.

How to calculate gross margin step by step

Here is the method on a single product. The figures are an example.

  1. Write down the selling price, net of discounts. In the example it is $50.00.
  2. Write down the full cost of one unit. The product costs $30.00 delivered to your warehouse.
  3. Subtract cost from price to get gross profit. $50.00 – $30.00 = $20.00.
  4. Divide gross profit by the selling price. $20.00 / $50.00 = 0.40.
  5. Multiply by 100. The gross margin is 40%.
  6. Divide the same gross profit by cost to get markup. $20.00 / $30.00 = 0.6667, a markup of 66.67%.
Line Amount How it is worked out
Selling price $50.00 What the customer pays, after discounts
Cost of the product -$30.00 What you pay the supplier, delivered
Gross profit $20.00 $50.00 – $30.00
Gross margin 40% $20.00 / $50.00 x 100
Markup 66.67% $20.00 / $30.00 x 100

That is the whole job of a gross profit margin calculator. Calculator.net’s margin calculator takes any two of cost, revenue, margin and profit and solves for the rest, and its own sample (cost $120, revenue $160) gives a 25% margin and a 33.33% markup, which matches the formulas above.

Now a second example with a realistic cost build, because most sellers undercount cost. A store sells a product for $40.00. It pays $18.00 to the supplier, $2.50 for inbound freight, $1.50 in import duty and $1.00 for packaging.

Cost line Amount
Supplier price $18.00
Inbound freight $2.50
Import duty $1.50
Packaging $1.00
Cost of goods sold per unit $23.00
Gross profit ($40.00 – $23.00) $17.00
Gross margin ($17.00 / $40.00) 42.5%
Markup ($17.00 / $23.00) 73.91%

Had the store used only the $18.00 supplier price, it would have reported a gross profit of $22.00 and a margin of 55%, a figure $5.00 per unit too generous. Leaving out freight, duty and packaging is the most common way a margin looks healthier than it is.

How do you calculate gross margin for a month or a product line?

Add up revenue and COGS for the period first, then divide once. Do not average the percentages of individual products, because a product that sells ten times as much should count ten times as much. Xero’s margin calculator page suggests running the figures over a quarter or a year rather than a single week, since prices and costs move.

Product line Net sales COGS Gross profit Gross margin
Line X $30,000 $15,000 $15,000 50%
Line Y $18,000 $16,200 $1,800 10%
Store total $48,000 $31,200 $16,800 35%

The blended margin is $16,800 / $48,000 = 35%. A simple average of the two percentages would say (50% + 10%) / 2 = 30%, which is wrong by five points because Line X carries more of the sales. Line Y earns a 10% margin and produces only $1,800 of the $16,800, so it is the line to reprice or drop before you spend anything promoting it.

Keep this view somewhere you will see it. A dashboard that shows margin by product, not just total revenue, catches a line sliding before it hurts the month. Our financial dashboard examples show which fields to chart, and our business intelligence dashboard services team builds the live version on top of your order and cost data.

What counts as cost of goods sold?

COGS is the direct cost of the items you sold. For a merchant, IRS Publication 334, Tax Guide for Small Business says to use the cost of all merchandise you bought for sale, and its Schedule C worksheet also lists freight-in among other costs of goods. It adds that labor is usually part of cost of goods sold only in a manufacturing or mining business.

For an online seller, Shopify’s gross margin guide gives a practical split. Classification varies by business and accounting method, so confirm yours with your accountant, and use the same split every period so the trend stays honest.

Usually counted in COGS Usually kept out of COGS
Supplier or wholesale price of the product Marketing and advertising
Raw materials Administrative salaries
Direct production labor Office rent and utilities
Inbound freight and import duties Interest payments
Packaging needed to prepare products for sale Income taxes

Payment fees and outbound shipping sit in a gray area. Many sellers track them as variable costs below gross margin, which is the contribution margin view, and that is the better number for ad decisions. Whichever way you treat them, say so on the report.

Gross margin vs markup: what is the difference?

Gross margin and markup describe the same dollars of gross profit. Margin divides by the selling price and markup divides by the cost. Because the price is larger than the cost whenever you make a profit, markup is always the bigger percentage, a point both Xero’s margin calculator page and Calculator.net’s margin calculator make.

Shopify’s gross margin guide uses a $60 product that sells for $100: the gross margin is $40 / $100 = 40%, and the markup is $40 / $60 = 66.7%. Same $40, two percentages.

The mix-up is expensive when you use a markup tool and a margin target together. Say your cost is $42 and you want a 35% gross margin:

Approach Price Gross profit Resulting margin
Add 35% markup to cost ($42 x 1.35) $56.70 $14.70 25.93%
Divide cost by (1 – 0.35) ($42 / 0.65) $64.62 $22.62 35.00%

Adding a 35% markup lands at a 25.93% margin, more than nine points short. Xero makes the same point in a smaller case: a 20% margin needs a 25% markup, not a 20% markup. A markup calculator is the right tool when you set a price from cost, and a margin calculator is the right tool when you report profit from a price. Keep them straight and you stop shipping prices that miss target.

How do you convert margin to markup, and markup to margin?

The conversion formulas are short, and Wikipedia’s gross margin entry lists the same pair:

Markup = margin / (1 – margin)

Margin = markup / (1 + markup)

Use decimals in the formulas, so 40% is 0.40. A 40% margin gives 0.40 / 0.60 = 0.6667, a 66.67% markup. A 100% markup gives 1 / 2 = 0.50, a 50% margin. The price multiplier, the number you multiply cost by to reach the price, is 1 / (1 – margin). If you already know your target, the first table is a ready margin to markup conversion.

Margin to markup conversion table

Target gross margin Markup on cost needed Price = cost multiplied by
10% 11.11% 1.111x
15% 17.65% 1.176x
20% 25% 1.25x
25% 33.33% 1.333x
30% 42.86% 1.429x
35% 53.85% 1.538x
40% 66.67% 1.667x
45% 81.82% 1.818x
50% 100% 2x
60% 150% 2.5x
70% 233.33% 3.333x
75% 300% 4x
80% 400% 5x

Markup to margin conversion table

Markup on cost Gross margin you actually get Price = cost multiplied by
10% 9.09% 1.1x
20% 16.67% 1.2x
25% 20% 1.25x
30% 23.08% 1.3x
40% 28.57% 1.4x
50% 33.33% 1.5x
75% 42.86% 1.75x
100% 50% 2x
150% 60% 2.5x
200% 66.67% 3x

How do you price a product for a target gross margin?

Start from the margin you need, not from a markup you like. Here is the method with a $42.00 landed cost and a 35% target.

  1. Work out the full unit cost. Use landed cost, as in the cost build above. Here it is $42.00.
  2. Write the target margin as a decimal. 35% becomes 0.35.
  3. Subtract it from 1. 1 – 0.35 = 0.65.
  4. Divide cost by that number. $42.00 / 0.65 = $64.615, so about $64.62.
  5. Check the result. Gross profit is $64.62 – $42.00 = $22.62, and $22.62 / $64.62 = 35.0%. The markup behind a 35% margin is 0.35 / 0.65 = 53.85%.

The reverse question comes up just as often: what is the most you can pay for a product and still hit a target? Use maximum cost = price x (1 – target margin). At a $64.62 price and a 35% target, the ceiling is $64.62 x 0.65 = $42.00.

Round to a sensible price point afterward and recheck the margin, because a $65.00 price on the same cost gives $23.00 of gross profit and a 35.38% margin. If prices change often, our AI dynamic pricing guide covers how teams adjust them without starting a price war.

What is a good gross margin?

A good gross margin is one that covers your operating costs and leaves the profit you want, and that level differs by industry. The Corporate Finance Institute also warns that ratios should be compared within the same industry, not across industries.

For a dated reference, here are figures from Aswath Damodaran’s margins by sector dataset at NYU Stern, as of January 2026. They cover US public companies, 5,994 firms in the total market row, so they describe large listed businesses and not a small online store. The dataset has no online retail row.

Industry group (US public companies) Firms Gross margin Net margin
Retail (Automotive) 34 21.96% 3.36%
Retail (Distributors) 62 30.57% 6.05%
Retail (General) 23 33.18% 5.61%
Retail (Building Supply) 14 34.22% 7.84%
Retail (Special Lines) 94 35.30% 5.19%
Household Products 110 51.04% 11.68%
Apparel 35 56.88% 3.85%
Software (System and Application) 309 71.72% 25.49%
Total market 5,994 37.76% 9.74%

Two things stand out. Gross margins vary by a factor of three between groups, from about 22% in automotive retail to about 72% in software. And net margins are far smaller than gross margins everywhere: general retail keeps 33.18% after cost of goods but only 5.61% after everything else. The gap between the two columns is your operating costs, interest and taxes.

To turn a benchmark into a personal target, work backward. Shopify’s gross margin guide gives an example: if operating expenses are 25% of sales and you want a 10% operating margin, you need a gross margin of at least 35%. Use your own operating expense ratio in that sum, not an industry average.

What does gross margin leave out, and how does it connect to ad spend?

Gross margin stops at cost of goods sold. It ignores marketing, payment fees, outbound shipping, returns handling, rent and salaries, which is why a healthy gross margin can sit beside a net loss. For paid ads the useful reading is gross profit per order. At a $50.00 price and $20.00 of gross profit, an order that cost more than $20.00 to acquire loses money before any other expense is counted.

That is the link to ROAS. Break-even ROAS is 1 divided by your margin before ad spend. If COGS were your only per-order cost, a 40% margin would give a break-even ROAS of 1 / 0.40 = 2.5. Shipping, fees and returns push the real figure higher, so use contribution margin for the ad decision. Our break-even ROAS calculator guide works through that adjustment, and the CPM calculator and formula shows how to turn a budget into what your impressions cost. Running the numbers on a thin-margin model before spending is also the lesson of our dropshipping break-even math.

Gross margin also does not tell you whether you can pay your bills this month. Cash timing is a separate problem, covered in our cash flow forecasting steps, and clean books make every margin figure more reliable, as our note on bookkeeping with AI tools explains.

How can you raise your gross margin?

Four levers move gross margin, and each has a trade-off.

  • Raise prices on the lines below target. Test on a small group first, as Shopify suggests, because a higher price can cost volume.
  • Lower cost of goods. Negotiate supplier rates, ask for volume pricing, and compare sources on total landed cost, not just the unit price.
  • Change the mix. Promote products with a higher margin. In the Line X and Line Y example, each $1,000 shifted from Line Y to Line X adds $400 of gross profit (a $500 gross profit less $100).
  • Tighten discounting. Set a minimum acceptable margin before a promotion goes out. At a 35% margin, a 10% discount on a $64.62 item cuts the price to $58.16 and the margin to 27.78%.

Small changes compound. Shopify notes that at $1 million in net sales, moving gross margin from 40% to 41% adds $10,000 of gross profit. On the $48,000 store above, one point of margin is $480.

Where should gross margin live in your systems?

A calculator answers one question at one moment. A business needs the answer for every product, every day, without anyone retyping costs into a sheet. That takes three inputs to stay current: supplier cost and landed cost per SKU, the price actually charged after discounts, and returns. When they sit in the store, the ERP or the accounting system and nowhere else, margin by product becomes a report instead of a project.

Our eCommerce development services team builds stores whose orders, costs and inventory feed one set of numbers. Our Odoo development services team connects purchasing, inventory and accounting in an ERP so landed cost updates when a supplier invoice arrives, and our business intelligence dashboard services team puts margin by product and channel on a live dashboard. To scope any of it for your business, contact us for a quotation.

Frequently Asked Questions

How does one calculate gross margin?

Subtract cost of goods sold from revenue to get gross profit, then divide gross profit by revenue and multiply by 100. With $48,000 of net sales and $31,200 of COGS, gross profit is $16,800 and gross margin is 35%. Use net sales, meaning revenue after returns, allowances and discounts, so the percentage reflects money you kept.

How is GP% calculated?

GP% is the gross profit percentage, another name for gross margin. It equals gross profit divided by revenue, times 100, so $20 of gross profit on a $50 sale is 40%. It is not markup, which divides the same $20 by the $30 cost to give 66.7%.

What is a good gross margin percentage?

It depends on the industry, because cost structures differ. NYU Stern’s January 2026 data for US public companies shows 26.31% for grocery and food retail, 33.18% for general retail, 56.88% for apparel and 71.72% for software, against 37.76% for the total market. A good margin for you is one high enough to cover your operating costs and leave the net profit you want.

Does 20% margin mean 20% profit?

A 20% gross margin means gross profit is 20% of the selling price, but that is not net profit, because gross profit still has to pay for rent, salaries, marketing and other overhead. It is also not a 20% markup. Reaching a 20% margin takes a 25% markup on cost, as Xero’s margin calculator page explains.

What is a 30% margin on $100?

It depends on which number is the $100. If the selling price is $100, a 30% margin is $30 of gross profit on a $70 cost. If the cost is $100, a 30% margin needs a price of $142.86, which gives $42.86 of gross profit and a 42.86% markup.

Is a 70% gross margin good for a company?

A 70% gross margin is strong for most businesses. In NYU Stern’s January 2026 data, software sits at 71.72%, while the retail groups run from 21.96% to 35.30% and apparel is at 56.88%. It is only good if operating costs such as sales, support and development leave a healthy net margin.

Is a 40% gross margin good?

A 40% gross margin is above the retail groups in NYU Stern’s January 2026 data, such as general retail at 33.18% and special lines at 35.30%, and below apparel at 56.88%. Whether it is enough depends on your operating expenses. In Shopify’s example, operating expenses of 25% of sales and a 10% operating margin goal require at least a 35% gross margin.

Is 30% profit margin too high?

There is no upper limit, but check which margin you mean. A 30% gross margin is ordinary for retail, since general retail averages 33.18% in NYU Stern’s January 2026 data. A 30% net margin would be unusual, because the same dataset shows 9.74% for the total market and 25.49% for software.

What is a profit margin calculator?

A profit margin calculator takes any two of cost, revenue, margin and profit and solves for the rest, and many also show markup, as the Calculator.net tool does. In these tools profit usually means revenue minus cost, so the result is a gross margin and not net profit. Use it for pricing and product reports, then check the costs it does not include.

What is the difference between gross margin and markup?

Both describe the same gross profit measured against different bases. Margin divides by the selling price and markup divides by the cost, so markup is always the larger percentage. A product that costs $60 and sells for $100 has a 40% margin and a 66.7% markup.

Bottom line

A gross margin calculator needs only a selling price and a cost. Gross margin is (revenue – COGS) / revenue, markup is the same profit over cost, and the two convert with margin / (1 – margin). Count the full landed cost, use net sales, price for a target margin by dividing cost by (1 – margin), and judge the result against your own operating costs and your own industry, not a headline average. Then recheck whenever a supplier price, freight rate or discount changes.

Keyur Ajmera
President & Partner, Commerce Pundit

I’m Keyur Ajmera, President & Partner at Commerce Pundit, where I bring over 17 years of experience at the intersection of digital commerce, technology, and AI innovation. Throughout my career, I’ve worked with industry leaders like Amazon, GE, Beats by Dre, NBC, CBS, the LAPD, and LA County, delivering transformative solutions that drive real impact. At Commerce Pundit, I lead a talented team across technology, operations, customer success, and strategy—all focused on helping our clients achieve extraordinary results. Under my leadership, we’ve grown our business to 9 figures, powered by a relentless commitment to innovation, AI-driven solutions, and customer success. Let’s connect and explore how we can harness technology and AI to elevate your business to new heights.

What our clients says

An assemblage of our most passionately crafted works alongside forward-thinking clients and friends throughout the years.

Eric Truong
Eric Truong CEO, LA Nails Supply
" Commerce Pundit’s collaboration created a stunning website representing our beauty nails business. Their SEO strategies boosted rankings and traffic.Transparent communication and prompt feedback incorporation exceeded expectations. "

0%

Increase in orders

0%

Increase in revenue

0%

Increase in site traffic

Contact Us