Home / Money / COGS Calculator

COGS Calculator – What Your Goods Really Cost You

Work out cost of goods sold from beginning inventory, purchases and ending inventory, then see gross profit and gross margin on your revenue. One formula, no mystery, and every figure updates as you type.

COGS = beginning + purchases − endingGross profit and margin includedFree, no sign-up

Your figures

Inventory and purchases, in dollars
Beginning inventory
Purchases
Ending inventory
Gross profit mode
Revenue

The default example is beginning inventory of $10,000 plus purchases of $40,000 minus ending inventory of $12,000, which gives COGS of $38,000. On revenue of $60,000 that leaves gross profit of $22,000 and a gross margin of 36.67 percent. Replace every figure with your own books: this calculator never claims an industry average, because your margin depends on your own costs.

Private by design: every number is worked out in your browser. Nothing you type is sent anywhere or stored.

Your result

Cost of goods sold
$38,000.00
$10,000.00 beginning plus $40,000.00 purchases minus $12,000.00 ending.
Goods available for sale$50,000.00
Gross profit$22,000.00
Gross margin36.67%
COGS as share of revenue63.33%
Copied
Key Takeaways
  • COGS is beginning inventory plus purchases minus ending inventory: $10,000.00 plus $40,000.00 minus $12,000.00 gives $38,000.00.
  • Purchases are the biggest part of the default build-up at 80.0% of goods available, so they move the answer most.
  • Enter revenue on top of COGS to see gross profit and gross margin; the margin, not the cost alone, is what a trend is read from.

Where the money goes

The bar shows the COGS build-up: what you started with, what you bought, and what is left at the end. In the default example, purchases are the biggest part.

Beginning $10,000.00 (20.0%) · Purchases $40,000.00 (80.0%) · Ending $12,000.00 · Goods available $50,000.00

The anchor case: beginning inventory of $10,000 plus purchases of $40,000 gives goods available of $50,000. Subtract ending inventory of $12,000 and COGS is $38,000. On revenue of $60,000, gross profit is $22,000 and gross margin is 36.67 percent. Change any input and the bar, the profit, and the margin all update at once.

How it works

Step 1.
Enter beginning inventory: the value of stock you held at the start of the period.
Step 2.
Add purchases made during the period, then subtract ending inventory: stock still on hand at the end.
Step 3.
Enter revenue to see gross profit and gross margin on top of COGS.

Understanding cost of goods sold

Goods available for sale is beginning inventory plus purchases: everything you could have sold in the period. Some of it is still sitting on the shelf at the end, and that part was not sold, so it is not a cost of this period. Subtracting ending inventory leaves exactly the cost of what was sold. If ending inventory rises, COGS falls, even though you bought just as much.

Gross profit is revenue minus COGS, in dollars: in the default example, $60,000 minus $38,000 is $22,000. Gross margin is that profit as a percentage of revenue: $22,000 divided by $60,000 is 36.67 percent. Profit tells you how much money is left; margin tells you how much of every sales dollar survives. Two businesses can share the same profit and have very different margins, which is why both numbers are shown.

Three worked cases: the default, a lean stockroom, and a warning sign

The default case is the page’s anchor, and every figure below was read from the calculator’s own displayed results for the stated inputs. Beginning inventory of $10,000 plus purchases of $40,000 gives goods available for sale of $50,000. Subtract ending inventory of $12,000 and cost of goods sold is $38,000. On revenue of $60,000 that leaves gross profit of $22,000 and a gross margin of 36.67 percent, with COGS as a share of revenue of 63.33 percent. The bar under the result shows the same build-up in shares: beginning inventory is 20.0 percent of goods available and purchases are 80.0 percent, which is simply $10,000 and $40,000 divided by $50,000. Change any input and the bar, the profit, and the margin all update at once, because the whole panel is one formula chain, not separate calculations.

The second case changes the shape of the business without changing the method. Set beginning inventory to $0, purchases to $50,000, ending inventory to $5,000, and revenue to $80,000, and the calculator shows goods available of $50,000, COGS of $45,000, gross profit of $35,000, a gross margin of 43.75 percent, and a COGS share of 56.25 percent. The goods available are the same $50,000 as the default, but the margin is higher, because less stock is left on the shelf at the end ($5,000 instead of $12,000) and revenue is higher ($80,000 instead of $60,000). This is the cleanest demonstration on the page of why ending inventory is subtracted rather than added: a smaller ending stock means more of the goods available were actually sold, so COGS rises from $38,000 to $45,000, yet profit still rises, because revenue rose further.

The third case is the one the base guide warns about, and it is worth running once so you recognise it. Keep the default beginning inventory of $10,000 and purchases of $40,000, but set ending inventory to $60,000 — higher than beginning plus purchases combined — and the calculator shows COGS of −$10,000.00, gross profit of $70,000.00, a gross margin of 116.67 percent, and a COGS share of −16.67 percent. Those numbers are the formula’s arithmetic, not a business result: as the base guide says, in honest books COGS cannot be negative, and a negative result usually means ending inventory was entered higher than beginning inventory plus purchases, which cannot happen for goods actually sold. Check the three inventory figures and correct the one that is wrong, rather than reporting the negative figure anywhere.

CaseBeginning + purchasesEndingCOGSRevenueGross profitGross margin
Default$10,000 + $40,000$12,000$38,000.00$60,000$22,000.0036.67%
Lean stockroom$0 + $50,000$5,000$45,000.00$80,000$35,000.0043.75%
Ending above goods available (warning)$10,000 + $40,000$60,000−$10,000.00$60,000$70,000.00116.67%
Zero stock (service-style)$0 + $0$0$0.00$50,000$50,000.00100.00%

The last row is the service-style edge case, also probed on the page: with all three inventory figures at $0 and revenue of $50,000, the calculator shows COGS of $0.00, gross profit of $50,000.00, a gross margin of 100.00 percent, and a COGS share of 0.00 percent. That is the formula working correctly on zero stock, and it matches the base guide’s point that a pure service business has no stock, so its direct costs are labour and materials used rather than inventory — the same revenue-minus-direct-costs idea still gives a gross profit figure, but you should enter those direct costs as purchases or as the appropriate cost lines in your own books, not leave the calculator at zero and call the 100 percent margin a real margin. A 100 percent gross margin means no direct costs were entered at all, which is a data entry state, not a business achievement.

Margin, markup, and why both numbers are shown

Gross profit is revenue minus COGS, in dollars, and gross margin is that profit as a percentage of revenue. In the default example, $60,000 minus $38,000 is $22,000, and $22,000 divided by $60,000 is 36.67 percent. Profit tells you how much money is left; margin tells you how much of every sales dollar survives, which is why the base guide insists both numbers are shown: two businesses can share the same profit and have very different margins. The lean-stockroom case proves it in reverse: profit rises from $22,000 to $35,000 and margin rises from 36.67 percent to 43.75 percent, but the two do not move together in general — a business with twice the revenue and twice the profit has the same margin, and a business with the same profit on half the revenue has double the margin.

Markup is the number most often confused with margin, and the calculator does not show it, so it is worth defining here to prevent the mix-up. Markup is profit as a percentage of cost, not of revenue: profit divided by COGS, times 100. On the default figures that works out to about 57.89 percent, because $22,000 divided by $38,000 is about 0.5789. On the lean-stockroom figures it works out to about 77.78 percent, because $35,000 divided by $45,000 is about 0.7778. Both figures are arithmetic on the calculator’s displayed results, shown here as “about” because the calculator itself does not display markup and the percentages are rounded to two places. The key point is directional: markup is always higher than margin for the same profit, because its denominator (cost) is smaller than margin’s denominator (revenue), and the gap widens as margin rises. A 36.67 percent margin is a 57.89 percent markup; a 43.75 percent margin is a 77.78 percent markup. If a supplier quotes you a markup and you compare it with this page’s margin, you are comparing different fractions, and you will overstate your profitability.

The COGS share of revenue is the complement of margin, and the panel shows it for the same reason it shows both profit and margin: it is the fraction of every sales dollar consumed by the goods themselves. In the default case the share is 63.33 percent, and 63.33 + 36.67 = 100. In the lean-stockroom case the share is 56.25 percent, and 56.25 + 43.75 = 100. In the warning case the share is −16.67 percent, and −16.67 + 116.67 = 100, which is another way of seeing that the warning case is arithmetically consistent but commercially meaningless. When you are deciding whether a margin movement is good news, look at the share too: a falling COGS share with steady revenue means your goods are costing less per sales dollar, whether because purchase prices fell, because ending stock was counted more fully, or because the sales mix shifted toward higher-priced goods. The calculator cannot tell you which of those happened — only your purchase records and stock counts can.

What the formula assumes, and what it cannot see

The formula is one line — COGS equals beginning inventory plus purchases minus ending inventory — but it rests on three assumptions that are worth stating, because each one is a place where real books diverge from the calculator. First, beginning inventory should equal the previous period’s ending inventory. Stock does not appear or disappear between periods except through purchases and sales, so if your opening figure differs from last period’s closing figure, one of the two counts is wrong, or stock was written off, damaged, or stolen in between, and that difference belongs in your records as a shrinkage or write-off entry, not silently absorbed into COGS. Second, the figures must cover the same period. Beginning inventory is the stock at the start of the period, purchases are the purchases during the period, and ending inventory is the stock at the end of the same period; mixing a quarterly purchase total with a monthly stock count gives a COGS figure for no real period at all.

Third, the calculator takes your inventory values as given: it does not choose a valuation method for you. Whether stock is valued at cost, at the price of the oldest purchases, the newest purchases, or an average is a decision your accounting method makes, and the base guide’s disclaimer applies here — this is a planning estimate from the figures you enter, not an official tax figure, and tax treatment of inventory depends on your accounting method and local rules, so confirm the final figure with your accountant before filing anything. The same caution covers the service-business case: the inventory formula fits businesses that sell goods, and a pure service business has no stock, so entering zero inventory and reading a 100 percent margin, as the probed edge case shows, is a statement about the inputs, not about the business.

Two movements deserve special attention because they mislead even careful readers. If ending inventory rises while purchases stay flat, COGS falls, even though you bought just as much — the base guide states this directly — because more of the goods available are still sitting on the shelf and therefore were not sold. That is correct accounting, but it means a rising ending stock flatters the current period’s profit while storing the cost for a later period, when that stock is eventually sold or written off. Conversely, if ending inventory falls because stock was damaged, stolen, or written down, COGS rises by the same amount, and the margin falls, even though nothing was sold at all. When a margin moves sharply from one period to the next, the first check is always the stock count: recount ending inventory before concluding that trading improved or worsened.

What moves the margin: two small changes on the default figures

Two what-if changes on the default figures show how sensitive margin is to each input, and both are plain arithmetic on the displayed default results, labelled as such because the calculator was not re-probed for these exact combinations — the method is the same formula, and you can verify either change by typing it in. First, suppose purchases rise by $5,000 with everything else unchanged: beginning $10,000, purchases $45,000, ending $12,000, revenue $60,000. Goods available become $55,000, COGS becomes $43,000, gross profit falls to $17,000, and margin falls to about 28.33 percent, because $17,000 divided by $60,000 is about 0.2833. A $5,000 cost increase on $60,000 of revenue costs more than eight points of margin. Second, suppose ending inventory rises by $5,000 instead, with purchases unchanged: beginning $10,000, purchases $40,000, ending $17,000, revenue $60,000. Goods available stay at $50,000, COGS falls to $33,000, gross profit rises to $27,000, and margin rises to 45.00 percent, because $27,000 divided by $60,000 is exactly 0.45.

Change from defaultCOGSGross profitGross margin
Default ($10,000 + $40,000 − $12,000, revenue $60,000)$38,000.00$22,000.0036.67%
Purchases +$5,000 (to $45,000)$43,000$17,000About 28.33%
Ending inventory +$5,000 (to $17,000)$33,000$27,00045.00%

The lesson of that table is not that a higher ending stock is good news — the previous section explains why it merely postpones cost — but that margin is a ratio, and ratios move on both sides. A supplier price rise hits margin through COGS; a stock-count correction hits margin through ending inventory; a discount hits margin through revenue, even if COGS does not move at all. When you use this calculator to plan, change one input at a time and watch which side of the ratio moved, and keep the inventory figures tied to actual counts: a margin computed from estimated stock is an estimated margin, and the base guide’s advice stands — confirm inventory values and final figures with a qualified accountant, and check local tax rules before filing. This calculator is a planning tool based on the figures you enter; it is not accounting, tax, or financial advice.

Reading a margin trend across periods

A single period’s margin is a snapshot; a trend across periods is the story, and the calculator is best used period by period, with the same discipline each time. Enter each period’s beginning inventory, purchases, ending inventory, and revenue separately, and write down the four outputs — COGS, goods available, gross profit, and margin — before moving to the next period. The continuity check from the earlier section is the first thing to verify between periods: this period’s beginning inventory should equal last period’s ending inventory, and any difference needs an explanation in your records, such as a write-off, damage, or theft, rather than being absorbed silently into COGS. A trend built on inconsistent openings is not a trend at all; it is a series of unrelated snapshots.

When a margin moves, decompose the movement before interpreting it. A margin change has exactly three possible drivers: revenue moved, COGS moved, or both moved, and COGS itself has three drivers: beginning inventory, purchases, and ending inventory. The what-if table in the previous section shows the scale: on $60,000 of revenue, a $5,000 purchase increase costs more than eight points of margin, while a $5,000 ending-stock increase adds more than eight points. So a margin that rises because ending stock was counted more fully is not an improvement in trading, and a margin that falls because a damaged batch was written off is not a deterioration in trading either — both are stock-count events wearing a margin costume. Separate the trading story (prices charged, prices paid, volumes sold) from the stock story (counts, write-offs, valuation) before drawing any conclusion about the business.

Three questions to take to your accountant complete the picture, and they are the right questions precisely because this calculator cannot answer them. First, is your inventory valued on the basis your tax rules require, and is it consistent from period to period? Second, are write-offs, shrinkage, and damaged stock recorded as their own entries, or are they disappearing into COGS through the ending-inventory figure? Third, does your gross profit figure include every direct cost of the goods sold — freight in, packaging, and any direct labour — or are some direct costs sitting in operating expenses, which would overstate gross profit and margin? The calculator’s formula is exact on the figures you enter; these questions are about whether the figures you enter are complete, and no calculator can answer them for you. That is why the base guide’s disclaimer is part of the method, not an afterthought: confirm inventory values and final figures with a qualified accountant, and check local tax rules before filing.

Common data-entry mistakes, and what each one does to the answer

The most common mistake is also the easiest to make: swapping beginning and ending inventory. On the default figures, entering beginning as $12,000 and ending as $10,000 instead of the other way round gives goods available of $52,000 rather than $50,000, COGS of $42,000 rather than $38,000, gross profit of $18,000 rather than $22,000, and a margin of 30.00 percent rather than 36.67 percent — every output moves, and the margin falls by more than six points, all from two transposed boxes. Those swapped figures are plain arithmetic on the default inputs, shown here so you can recognise the signature: if your margin looks several points lower than you expected and nothing about trading changed, check the two inventory boxes before anything else, because a swap is more likely than a sudden change in your business.

The second mistake is a period mismatch: entering revenue for one period against inventory for another. The formula assumes all four figures cover the same period, and mixing a quarterly purchase total with a monthly stock count, or monthly revenue with quarterly inventory, gives a COGS figure for no real period at all. The signature is a margin that looks impossible — far above or far below your usual range — with no corresponding change in prices or volumes. The fix is bookkeeping, not arithmetic: align all four figures to the same period boundary, and use the continuity check, this period’s beginning equals last period’s ending, as the test that the alignment is right.

The third mistake is valuing ending inventory at selling price instead of cost. Ending inventory in this formula is the cost of the stock still on hand, not what it would sell for, and entering it at retail overstates ending inventory, understates COGS by the same amount, and overstates gross profit and margin by the same amount. The direction is the giveaway: a margin that looks too good, with ending stock that looks too valuable, usually means the stock was priced at the shelf rather than at cost. The fourth mistake is the mirror image in the purchases box: whether freight in, packaging, and other costs of getting goods ready for sale belong in purchases depends on your books, and leaving a genuine direct cost out understates COGS and overstates margin. Neither mistake is detectable from the calculator’s outputs alone — both produce plausible-looking numbers — which is why the accountant questions in the previous section matter more than any further arithmetic on this page.

A profit bridge between the two probed cases shows how to read a movement without guessing. From the default case to the lean-stockroom case, revenue rises from $60,000 to $80,000, a gain of $20,000; COGS rises from $38,000 to $45,000, a cost of $7,000; and gross profit rises from $22,000 to $35,000, a gain of $13,000, which is exactly $20,000 minus $7,000. The margin rises from 36.67 percent to 43.75 percent, but the bridge is more informative than the margin alone, because it separates the revenue story from the cost story: most of the profit gain came from selling more, not from buying cheaper, and the COGS rise itself came from a smaller ending stock, not from higher purchases. Whenever you compare two periods, build the bridge first — revenue change, minus COGS change, equals profit change — and only then look at the margin, which is the ratio that summarises the bridge without explaining it.

Keep one habit from this page above all: never let a margin figure travel without its four inputs. A margin of 36.67 percent on its own says nothing about whether the business sold more, bought cheaper, or simply counted more stock at the end, and a margin quoted without beginning inventory, purchases, ending inventory, and revenue cannot be checked, repeated, or compared. File the four inputs with every margin you report, period by period, and the continuity check, the bridge, and the accountant questions all become routine rather than rescue work.

Reading COGS on the balance sheet: inventory methods

The COGS formula is one line. The inventory method decides which costs the line picks up, and in rising prices the method is the answer.

Inventory is carried on the balance sheet at cost, and the method decides which costs leave the balance sheet as COGS when goods are sold and which stay behind as ending inventory. First in, first out, FIFO, assumes the oldest goods are sold first, so in rising prices the cheapest, oldest costs become COGS and the newest, dearest costs stay in ending inventory: COGS is lower, ending inventory is higher, and reported profit is higher. Last in, first out, LIFO, assumes the newest goods are sold first, so in rising prices the dearest costs become COGS and the oldest costs stay behind: COGS is higher, ending inventory is lower, and reported profit is lower. The weighted average method smooths both, charging each sale the average cost of the goods available. The goods sold are the same goods under all three methods; only the assignment of costs differs, and the difference lands in COGS, in ending inventory, and in profit, all at once.

The choice of method is not free in every jurisdiction. LIFO is permitted under United States generally accepted accounting principles, US GAAP, and is not permitted under International Financial Reporting Standards, IFRS, so a business reporting under IFRS cannot use LIFO however its costs are moving, while a business reporting under US GAAP can, subject to the conformity and disclosure rules that come with it. Whatever method is chosen must be applied consistently from period to period, and a change of method must be disclosed, because comparability across periods is the point of the rule: a business that switches from FIFO to LIFO in a rising market without disclosure has changed its reported profit by changing its method, not by changing its trading. The roll-forward ties the periods together: beginning inventory this period is ending inventory last period, and any break in that chain is an error or an adjustment that needs explaining, not a rounding difference. The companion guide works the formula, the manufacturing case, and worked examples from the same method, so the figures here and the figures there can be read together.

Frequently asked questions

What is the COGS formula?

COGS equals beginning inventory plus purchases minus ending inventory. Add what you started with to what you bought, then subtract what is still on hand at the end of the period.

What is the difference between COGS and operating expenses?

COGS covers the direct cost of the goods you sold, such as stock and materials. Operating expenses cover running the business, such as rent, salaries, and marketing. Gross profit is revenue minus COGS only, before operating expenses are taken out.

How is gross margin calculated?

Gross margin equals gross profit divided by revenue, times 100. In the default example, gross profit of $22,000 divided by revenue of $60,000 gives 36.67 percent.

Can COGS be negative?

In honest books, no. A negative result usually means ending inventory was entered higher than beginning inventory plus purchases, which cannot happen for goods actually sold. Check the three inventory figures and correct the one that is wrong.

Does this calculator handle services?

It handles the inventory formula, which fits businesses that sell goods. A pure service business has no stock, so its direct costs are labour and materials used, and the same revenue minus direct costs idea still gives a gross profit figure.

Is this an official tax figure?

No. This is a planning estimate from the figures you enter. Tax treatment of inventory depends on your accounting method and local rules, so confirm the final figure with your accountant before filing anything.

What happens if ending inventory is higher than beginning inventory plus purchases?

The calculator still applies the formula, and the result is a warning sign, not a business result. With beginning inventory of $10,000, purchases of $40,000, and ending inventory of $60,000, it shows COGS of −$10,000.00, gross profit of $70,000.00, and a gross margin of 116.67 percent. In honest books COGS cannot be negative: a negative result usually means one of the three inventory figures is wrong, so check them and correct the one that is wrong rather than reporting the negative figure.

Is gross margin the same as markup?

No. Gross margin is profit as a percentage of revenue: on the default figures, $22,000 divided by $60,000 is 36.67 percent. Markup is profit as a percentage of cost: on the same figures, $22,000 divided by $38,000 works out to about 57.89 percent. Markup is always higher than margin for the same profit, because its denominator is smaller, so do not compare a supplier’s markup with this page’s margin.

Can a service business use this calculator?

It handles the inventory formula, which fits businesses that sell goods. A pure service business has no stock: with all three inventory figures at $0 and revenue of $50,000, the calculator shows COGS of $0.00, gross profit of $50,000.00, and a gross margin of 100.00 percent. That 100 percent is a statement about the inputs, not about the business — a service business should enter its direct costs, labour and materials used, as the cost lines in its own books, and use the same revenue-minus-direct-costs idea to get its gross profit figure.

Should beginning inventory equal last period’s ending inventory?

Yes, as a continuity check. Stock does not appear or disappear between periods except through purchases and sales, so if your opening figure differs from last period’s closing figure, one of the two counts is wrong, or stock was written off, damaged, or stolen in between. Record that difference as a shrinkage or write-off entry in your own books rather than letting it disappear silently into COGS.

How does FIFO change COGS when prices are rising?

FIFO assumes the oldest goods are sold first, so in rising prices the cheapest, oldest costs become COGS and the newest, dearest costs stay in ending inventory. COGS is lower, ending inventory is higher, and reported profit is higher than under LIFO on the same sales. The goods sold are identical; only the assignment of costs differs, and the difference lands in COGS, ending inventory, and profit together.

Can a business switch inventory methods?

Only with consistency and disclosure. The method must be applied consistently from period to period, and a change of method must be disclosed so that figures remain comparable across periods, because a switch in a rising market changes reported profit without changing trading. LIFO is permitted under US GAAP and not permitted under IFRS, so the available methods also depend on the reporting framework. Take a change of method past an accountant before applying it, and never switch methods to manufacture a profit figure.

Why does COGS differ between two businesses with the same sales?

Because COGS follows costs, method, and cut-off, not sales. Two businesses with the same sales can carry different purchase costs, different freight and labour in cost, different inventory methods in rising prices, and different period cut-offs for purchases and sales, and each difference lands in COGS. Compare gross margin only between businesses on the same method and the same basis, and read the inventory note in the accounts before concluding that one business is more efficient than another on COGS alone.

Disclaimer: this calculator is a planning tool based on the figures you enter. It is not accounting, tax, or financial advice. Confirm inventory values and final figures with a qualified accountant, and check local tax rules before filing.

↑