Business & Operations Tools

Cost of Goods Sold (COGS) Calculator

Calculate cost of goods sold from opening stock, purchases and closing stock, or from purchase lots by FIFO, LIFO or weighted average, with gross margin.

  • COGS
  • Ending inventory value
  • Gross margin
Runs in your browser

Everything you paste, type or drop is processed in this browser tab. It is not uploaded, logged, stored or sent to analytics.

COGS workspace

1 How you want to work it out

Try it:
Method

2 Inventory and costs

Shipping, duty and handling to get goods to you. Shipping to customers is a selling expense, not COGS.

3 Cost of goods sold

Enter beginning inventory, purchases and ending inventory - or your purchase lots and units sold - to see cost of goods sold.

What the Cost of Goods Sold (COGS) Calculator does

This COGS calculator works out cost of goods sold two ways: with the year-end formula (beginning inventory + purchases + freight-in - returns + production costs - ending inventory, as on US Schedule C), or from your purchase lots by FIFO, LIFO or weighted average, side by side. It adds gross profit and gross margin when you enter net sales.

Cost of goods sold is the cost of the stock you actually sold - not everything you bought. Getting it right sets your gross margin, your taxable profit and the value of the stock still on the shelves. The lots view shows why the choice of method matters: when prices rise, FIFO and LIFO give different profits from identical trading. Everything is calculated in your browser; nothing you enter leaves the page.

How to use it

  1. Pick the method. Use the formula if you count stock at the start and end of the period; use purchase lots if you know what each batch cost and how many units you sold.
  2. For the formula, enter beginning inventory, purchases, freight-in, purchase returns and discounts, and - if you make products - direct labour, materials and other production costs, then ending inventory.
  3. For lots, list each batch on its own line as quantity and unit cost, oldest first and starting with opening stock, enter the units sold, and pick the method to report. All three methods are compared in the table.
  4. Add net sales to see gross profit and gross margin, then copy the summary, download a CSV or print the working.

Reading the results

Cost of goods sold sits between revenue and gross profit: net sales minus COGS is gross profit, and gross profit divided by net sales is gross margin. A rising COGS ratio with flat prices usually means purchase costs went up, stock was written off or freight got dearer.

In the lots view, FIFO charges the oldest costs to sales and leaves the newest in stock; LIFO does the reverse; weighted average spreads one average cost over everything. When costs rise, LIFO shows the highest COGS and the lowest profit, FIFO the lowest COGS and the highest closing stock value. When costs fall the order flips.

Over the life of the business the total cost is the same whichever method you use - the methods only change in which period each cost is recognised. Sell every unit and all three give the same COGS.

Worked example: a shop's year-end figures, then the same stock by lots

Formula: beginning inventory 40,000 + purchases 250,000 + freight-in 6,000 - purchase returns 4,000 = 292,000 of goods available for sale. Ending inventory is 52,000, so COGS = 292,000 - 52,000 = 240,000. With net sales of 400,000, gross profit is 160,000 and gross margin 40%.

Lots: opening stock 100 units at 10, then 200 at 11, 150 at 12.50 and 50 at 13 - 500 units costing 5,725. 380 units are sold for 7,600.

FIFO: 100 x 10 + 200 x 11 + 80 x 12.50 = 4,200 COGS, leaving 1,525 in stock (44.7% margin). LIFO: 50 x 13 + 150 x 12.50 + 180 x 11 = 4,505, leaving 1,220 (40.7% margin). Weighted average: 5,725 / 500 = 11.45 a unit, so 380 x 11.45 = 4,351, leaving 1,374 (42.8% margin).

Formulas and scoring rules

Cost of goods sold (periodic)
COGS = beginning inventory + purchases + freight-in - purchase returns and discounts + direct labour + materials + other costs - ending inventoryThe same order as IRS Schedule C lines 35 to 42.
Goods available for sale
goods available = beginning inventory + net purchases + production costs
FIFO and LIFO
COGS = sum of units sold taken from the oldest (FIFO) or newest (LIFO) lots x each lot's unit cost
Weighted average (periodic)
average cost = total cost of all lots / total units; COGS = units sold x average cost
Gross profit and margin
gross profit = net sales - COGS; gross margin = gross profit / net salesNothing is rounded while calculating; money is shown to whole units and margins to one decimal place.

United States: Schedule C, inventory methods and LIFO

Sole proprietors report cost of goods sold on Schedule C, lines 35 to 42, in the same order as the formula here (IRS Publication 334). IRS Publication 538 describes the cost-flow assumptions - specific identification, FIFO and LIFO - and says the cost of purchased goods is the invoice price less discounts plus transportation or other charges incurred in acquiring them, which is why freight-in belongs in COGS.

To adopt LIFO for tax you file Form 970 with the return for the first year you use it. The LIFO conformity rule in 26 U.S.C. 472(c) means a business using LIFO for tax generally has to use it in reports to owners and for credit purposes too. Small businesses that meet the gross receipts test may be able to use a simpler inventory method; Publication 538 explains the exception.

IFRS countries (UK, EU, India and others)

IAS 2 Inventories assigns cost by specific identification for items that are not ordinarily interchangeable, and by FIFO or weighted average for items that are. LIFO is not one of the permitted formulas, so companies reporting under IFRS or Ind AS cannot use it. UK small companies following FRS 102 apply a similar rule. The LIFO result shown here is for comparison and US use only.

What belongs in COGS - and what does not

COGS includes the cost of getting stock into a saleable state: the purchase price less returns and discounts, inbound freight and duty, and for manufacturers direct labour, materials and production overheads. Shipping goods out to customers, marketing, office rent and general wages are operating expenses below gross profit. Stock that is lost, stolen or written down still leaves the business through COGS when opening and closing inventories are counted correctly.

Limitations: what the result does not prove

  • The lots view is periodic: it assigns cost once at the end of the period. A perpetual system that recalculates after each sale can give different LIFO and moving-average results (FIFO comes out the same either way).
  • It does not apply the uniform capitalization (UNICAP) rules, lower-of-cost-or-market or net realisable value write-downs, or dollar-value LIFO; those need your full records.
  • Which method you may use, and whether you can change it, is decided by your accounting framework and tax authority. This is an estimate, not tax or accounting advice: check with an accountant, CPA or enrolled agent before filing.

Privacy: where your data goes

Everything you paste, type or drop is processed in this browser tab. It is not uploaded, logged, stored or sent to analytics. Session recording and tag-manager scripts are switched off on this page.

Standards and sources

Frequently asked questions

How do I calculate COGS?

Add beginning inventory, purchases and freight-in, subtract purchase returns and discounts, add any direct labour and production costs, then subtract ending inventory. With 40,000 + 250,000 + 6,000 - 4,000 - 52,000 the cost of goods sold is 240,000.

FIFO vs LIFO: which lowers tax?

LIFO lowers taxable profit when purchase costs are rising, because the newest and dearest units are charged to sales first. When costs fall, FIFO gives the higher cost instead. LIFO is only available for US tax, needs Form 970 and generally has to be used in your financial reports as well.

Is shipping part of COGS?

Inbound shipping - freight to bring goods to you - is part of COGS because it is a cost of acquiring the stock. Outbound shipping to deliver orders to customers is normally a selling or operating expense, not cost of goods sold.

What is the difference between COGS and operating expenses?

COGS is the direct cost of the products you sold, while operating expenses are the costs of running the business, such as rent, marketing, salaries and software. COGS comes off revenue to give gross profit; operating expenses come off gross profit to give operating profit.

How does COGS affect gross margin?

Gross margin is net sales minus COGS, divided by net sales, so every extra unit of COGS lowers the margin one for one. A 400,000 revenue business with 240,000 of COGS has a 40% gross margin; if COGS rose to 260,000 the margin would fall to 35%.

Is LIFO allowed under IFRS?

No, IAS 2 permits only FIFO and weighted average for interchangeable items (plus specific identification where items are not interchangeable). Companies reporting under IFRS, Ind AS or similar frameworks therefore cannot use LIFO for their accounts.

Why is my weighted average COGS between FIFO and LIFO?

Weighted average spreads one blended unit cost across every unit sold and every unit left in stock, so it always lands between the oldest-first and newest-first answers. In the worked example it gives 4,351, between FIFO's 4,200 and LIFO's 4,505.

Last reviewed by the A2Z.Tools team against the sources listed above.

Rate this tool

Was this tool useful? Your feedback helps us improve it.

No ratings yet — be the first to rate this tool.
Your rating (required)
0 / 2000

Please do not include passwords, payment details or other sensitive information.

Your feedback is sent privately to the A2Z.Tools team and will not be posted publicly.

Advertisement