Cost of Goods Sold (COGS) Calculator
Find what the goods you sold really cost you, your gross profit and margin, and how FIFO, LIFO and average costing change the answer.
Freight, duties and handling to get stock to you are added. Returns to suppliers and early-payment or bulk discounts are taken off.
Labour and factory overhead (power, machine wear, factory rent) that went into goods made this period. Units sold gives your cost per unit.
Lots in date order, oldest first. Lot 1 can be your opening stock. Put freight in the unit cost.
FIFO vs LIFO vs weighted average
| Method | COGS | Closing stock | Gross profit |
|---|
Same lots, same units sold. Each method only splits the total cost differently between goods sold and stock left. LIFO isn't allowed under IFRS (India, UK, EU, Gulf and most countries); it is allowed under US GAAP.
How your cost of goods sold is worked out
COGS = opening stock + purchases − closing stock. Gross profit = revenue − COGS.
- 1
Goods available
$20,000 + $50,000= $70,000
- 2
Less closing stock
$70,000 − $15,000= $55,000 COGS
- 3
Gross profit
$90,000− $55,000= $35,000
- 4
Gross margin
$35,000÷ $90,000= 38.9%
Read more: the formula, a worked example, FIFO vs LIFO and notes
Cost of goods sold (COGS) is what the stock you sold in a period cost you: the purchase price plus the costs of getting it ready to sell. Take it away from revenue and you get gross profit, before rent, wages for sales staff, marketing and other running costs.
The formula
COGS = opening inventory + net purchases − closing inventory
net purchases = purchases + freight-in and duties − purchase returns − purchase discounts
for makers: COGS = opening inventory + net purchases + direct labour + manufacturing overhead − closing inventory
per unit: COGS = units sold × cost per unit
FIFO: units sold are costed from the oldest lots first
LIFO: units sold are costed from the newest lots first
weighted average cost = total cost of all lots ÷ total units; COGS = units sold × average cost
closing inventory = total cost of all lots − COGS
gross profit = revenue − COGS
gross margin = gross profit ÷ revenue
markup = gross profit ÷ COGS
inventory turnover = COGS ÷ ((opening + closing inventory) ÷ 2)
days in inventory = days in the period ÷ turnover
Worked example
A shop starts the year with $20,000 of stock, buys $50,000 more and counts $15,000 left at the end. Goods available for sale = 20,000 + 50,000 = $70,000. COGS = 70,000 − 15,000 = $55,000.
Its revenue was $90,000. Gross profit = 90,000 − 55,000 = $35,000. Gross margin = 35,000 ÷ 90,000 = 38.89%, and markup = 35,000 ÷ 55,000 = 63.64%.
The same shop in Advanced mode
The $50,000 of purchases came with $2,000 of freight and duties, $1,500 of goods sent back and $500 of supplier discounts. Net purchases = 50,000 + 2,000 − 1,500 − 500 = $50,000, so COGS stays $55,000. It sold 2,200 units: 55,000 ÷ 2,200 = $25.00 a unit, the same answer as the units × cost method (2,200 × $25 = $55,000).
Average inventory = (20,000 + 15,000) ÷ 2 = $17,500. Turnover = 55,000 ÷ 17,500 = 3.14 times a year, and days in inventory = 365 ÷ 3.1429 = 116.14 days.
FIFO, LIFO and weighted average
A trader holds 1,000 units at $20 (opening stock, $20,000), buys 1,500 at $24 ($36,000) and then 2,000 at $30 ($60,000): 4,500 units costing $116,000. It sells 3,000 units.
- FIFO: 1,000 × 20 + 1,500 × 24 + 500 × 30 = 20,000 + 36,000 + 15,000 = $71,000. Left: 1,500 × 30 = $45,000.
- LIFO: 2,000 × 30 + 1,000 × 24 = 60,000 + 24,000 = $84,000. Left: 500 × 24 + 1,000 × 20 = $32,000.
- Weighted average: 116,000 ÷ 4,500 = $25.78 a unit; 3,000 × 116,000 ÷ 4,500 = $77,333.33. Left: 116,000 − 77,333.33 = $38,666.67.
With $90,000 of sales, gross profit is $19,000 (21.1%) under FIFO, $12,666.67 (14.1%) under weighted average and $6,000 (6.7%) under LIFO. Prices were rising, so LIFO puts the dearest costs into COGS: lower profit, lower tax, but stock on the balance sheet at old prices.
Notes
- What's in COGS: purchase cost, freight-in, import duties, and for makers direct materials, direct labour and factory overhead. Not in COGS: shipping to customers, sales staff, marketing, office rent and admin.
- LIFO and the rules: IFRS (IAS 2), used in India as Ind AS 2, the UK, the EU and the Gulf states, bans LIFO. US GAAP allows it, and the US tax "LIFO conformity rule" means a business using LIFO for tax must use it in its accounts too.
- This calculator uses the periodic method: all lots in the period are pooled, then units sold are taken out. A perpetual system that costs each sale on the day can give slightly different LIFO and average figures.
- Value closing stock at cost (or lower if it's damaged or can't be sold at that price: the lower of cost and net realisable value).
- In the lots method, turnover uses lot 1 as the opening stock.
Standard accounting definitions; LIFO rules from IAS 2 and US GAAP (ASC 330) (standards, not rechecked against the source text). Results are a guide, not accounting or tax advice.
Common questions
How do you calculate cost of goods sold?
COGS = opening inventory + purchases − closing inventory. If you started the year with $20,000 of stock, bought $50,000 more and had $15,000 left at the end, the goods you sold cost 20,000 + 50,000 − 15,000 = $55,000.
What goes into purchases for COGS?
Net purchases: what you paid for stock, plus freight-in, import duties and other costs of getting it to you, minus purchase returns and discounts. Makers also add direct labour and factory overhead. Selling costs, office rent and marketing are not part of COGS.
What is the difference between FIFO, LIFO and weighted average?
They decide which purchase costs count as sold. FIFO (first in, first out) uses the oldest costs first, LIFO (last in, first out) the newest, and weighted average uses the average cost of everything available. When prices rise, FIFO gives the lowest COGS and the highest closing stock, LIFO the opposite.
Is LIFO allowed?
Not under IFRS, which is used in India (Ind AS), the UK, the EU, the Gulf states and most of the world. LIFO is allowed under US GAAP, and US businesses that use it for tax must also use it in their accounts. FIFO and weighted average are allowed under both.
How do gross profit and gross margin relate to COGS?
Gross profit = revenue − COGS. Gross margin = gross profit ÷ revenue. With revenue of $90,000 and COGS of $55,000, gross profit is $35,000 and gross margin is 35,000 ÷ 90,000 = 38.9%. Markup is gross profit ÷ COGS = 63.6%.
Is COGS the same as cost of sales?
Mostly, yes. Cost of goods sold is the usual name for businesses that sell products; cost of sales or cost of revenue is often used by service businesses and in IFRS accounts. Both cover the direct cost of what you sold in the period.
Related calculators
Made by Zulu Calculator, part of AlphaZulu LLC. Formulas are shown in full and rule figures are checked against official sources; see how we build calculators.