Cost of Goods Sold (COGS) Calculator
The classic COGS formula plus something no basic calculator offers: method-accurate COGS from your actual purchase batches.
Quick COGS Formula
COGS = Beginning Inventory + Purchases − Ending Inventory
Method-Accurate COGS (FIFO / LIFO / Weighted Average)
Don't know your ending inventory value yet? Enter your purchase batches and units sold — this derives COGS and ending inventory under the method you choose.
Purchases (oldest first)
Results using :
What Is Cost of Goods Sold?
COGS is the direct cost of the products you actually sold during a period — merchandise purchase costs, raw materials, inbound freight, and (for manufacturers) direct labor and production overhead. Revenue minus COGS is your gross profit, so getting COGS right is the foundation of every margin decision you make. It excludes operating expenses like marketing, rent, and admin salaries.
The COGS Formula
COGS = Beginning Inventory + Purchases − Ending Inventory
The formula is simple; the subtlety is in valuing ending inventory. That's where the cost flow method matters — the same period of sales produces different COGS under each:
Worked Example: COGS Under Each Method
Buy 100 units @ $10, then 200 @ $12, then 150 @ $14 ($5,500 for 450 units). Sell 320 units:
With rising costs, LIFO reports $460 more COGS than FIFO on identical sales — lower gross profit, lower taxable income. That trade-off is the heart of the FIFO vs LIFO decision, and it's why inventory valuation is a tax strategy, not just bookkeeping.
What Counts in COGS (and What Doesn't)
Included
- Purchase price of goods for resale
- Raw materials and components
- Inbound freight and duties
- Direct production labor
- Factory/production overhead
Excluded
- Marketing and advertising
- Rent and utilities (non-production)
- Admin and sales salaries
- Outbound shipping to customers
- Research and development
For a deeper dive into optimizing this number, read our Small Business Guide to COGS.
Frequently Asked Questions
How do you calculate COGS?
Beginning inventory + purchases − ending inventory. If you don't know ending inventory yet, use the method-accurate calculator above: it allocates your purchase costs to units sold under FIFO, LIFO, or Weighted Average and gives you both numbers at once.
Does the valuation method really change COGS?
Yes — in the example above the spread between FIFO and LIFO is $460 on just $5,500 of purchases (over 8%). Scaled to real revenue, method choice routinely shifts reported profit by five to six figures a year.
How do I calculate COGS in Excel?
The basic identity is one formula. FIFO layer allocation is the hard part in a spreadsheet — grab our free FIFO Excel template with the allocation formulas already built.
Is COGS the same as cost of sales?
Mostly. "Cost of sales" is the broader term service businesses use; product businesses typically say COGS. On financial statements they occupy the same line: direct costs of what was sold.
COGS From Your Real Transactions
Upload a CSV of your purchases and sales — get COGS, ending inventory, and per-unit costs under every method, exportable and saved.
Start Free — 500 Transactions Included