Quick answer: What is the cost of goods sold formula?
Opening inventory, plus everything purchased during the period, minus whatever is still in stock at the end. Open at $61,000, buy $224,000 including inbound freight, count $73,000 remaining, and cost of goods sold is $212,000. Only costs tied directly to obtaining or producing those units qualify — the goods, inbound freight, and the labour that made or delivered them. Premises, advertising and administration belong to overhead instead. Firms selling services run the identical calculation under the heading cost of services. Kantivo carries Cost of Goods Sold as a dedicated account type, so gross profit appears as a genuine subtotal on the income statement, and perpetual inventory writes the cost entry itself as each product sells.
A roastery and a rival across town both banked $395,000 last year. One is expanding; the other is quietly borrowing to cover payroll. Revenue says nothing about which is which. The answer is buried one line lower, in the cost of what they sold — and in how much of each sale survived it. For any business that moves product, cost of goods sold is the number that decides whether the top line means anything at all.
What follows is how to calculate cost of goods sold from the ground up: the arithmetic, the judgement calls about which costs qualify, the version service firms need, the entries under each inventory approach, and the handful of habits that leave the figure wrong year after year.
The Cost Your Sales Actually Carried
COGS answers one question: what did the items that left the building cost you to get? Not the items you paid for this month — the ones that actually sold.
Order 900 kilos of green coffee in April and roast and ship 300 of them, and only those 300 kilos represent an expense. The remaining 600 are still an asset on the balance sheet, patiently waiting for the month a customer takes them. Accountants call this matching: a cost belongs to the period whose revenue it helped create, not the period your supplier happened to invoice you.
Placed immediately under revenue on the income statement, the subtraction produces gross profit:
| Line | Amount | Meaning |
|---|---|---|
| Revenue | $395,000 | What customers paid |
| Cost of Goods Sold | ($212,000) | The direct cost of those sales |
| Gross Profit | $183,000 | Left to fund the business (46.3%) |
| Operating Expenses | ($141,000) | Premises, admin, marketing, insurance |
| Net Profit | $42,000 | What survived everything |
Collapse COGS into general expenses and gross profit disappears from the statement entirely. What you lose with it is the ability to distinguish a pricing failure from an overhead problem — two situations that look identical at the bottom line and call for opposite responses.
How to Calculate Cost of Goods Sold, Step by Step
What is the formula for cost of goods sold?
Three figures, one subtraction:
COGS = Opening Inventory + Purchases − Closing Inventory
Read it as a stock reconciliation and it stops feeling like accounting. Whatever you started with plus whatever you brought in is everything you could have sold. Deduct what's still on the racks and you're left with what went out.
Here it is on Copper Kettle Coffee Roasters over a full year:
| Component | Amount | Source |
|---|---|---|
| Opening inventory (Jan 1) | $61,000 | Last year's closing figure, carried forward |
| Green coffee and packaging purchased | $215,000 | Supplier invoices |
| Inbound freight and duty | $9,000 | Getting it to the roastery |
| = Available for sale | $285,000 | Everything that could have sold |
| − Closing inventory (Dec 31) | ($73,000) | Counted, valued at cost |
| = Cost of goods sold | $212,000 | What sold, at your cost |
Producers substitute one line. When you manufacture rather than resell, “purchases” becomes cost of goods manufactured: materials consumed, production labour and factory overhead, tracked through raw materials, work in process and finished goods. The equation keeps its shape; only that middle figure takes more effort to assemble.
Direct or Overhead? Sorting the Two Halves
What is included in cost of goods sold?
Only direct costs — the ones that exist because of the specific units you sold. A single question resolves nearly every borderline case:
Picture next month with no sales whatsoever. Which costs still turn up? Those are overhead. The ones that vanish alongside the sales are direct.
The lease payment arrives regardless, so it's overhead. The green coffee only exists because you were going to roast and sell it, so it's COGS.
| Cost | Classified as | Reasoning |
|---|---|---|
| Purchase cost of stock for resale | COGS | The product itself |
| Raw materials, packaging, components | COGS | Physically part of what ships |
| Inbound freight, customs duty | COGS | Cost of acquiring the stock |
| Pay of production or billable staff | COGS | Direct labour |
| Subcontractors engaged for a job | COGS | Attributable to that job |
| Plant rent, machinery depreciation | COGS | Production overhead |
| Outbound delivery to customers | Overhead | A cost of selling, not of making |
| Commission paid to salespeople | Overhead | Wins the order, doesn't create the product |
| Administrative and bookkeeping wages | Overhead | Payable regardless of volume |
| Advertising and promotion | Overhead | Generates demand, not goods |
| Office lease, insurance, subscriptions | Overhead | Fixed running costs |
Is shipping included in cost of goods sold?
Direction decides it. Inbound freight forms part of what your stock cost, so it rides along in inventory value and lands in COGS on the day the item sells. Outbound delivery is a selling cost and reports below gross profit.
This isn't pedantry. Outbound freight climbs with order volume, so leaving it inside COGS makes margin look thinner in your strongest months and healthier in your weakest — precisely the opposite of the truth. Separate them even when one courier statement covers both. The broader version of this sorting problem is covered in our piece on categorising business expenses.
When You Sell Hours Instead of Objects
Do service businesses have cost of goods sold?
They do — typically recorded as cost of services. Leaving it out is one of the quiet, costly habits in professional-services bookkeeping: every payroll dollar goes into a single Wages account beneath gross profit, and the firm ends up with no gross margin and no way to separate a client that pays for itself from one that doesn't.
Hollis Mechanical, an HVAC contractor, bills $62,000 in a month:
| Cost | Amount | Classified as |
|---|---|---|
| Technician wages on billable calls | $23,000 | Cost of services |
| Employer payroll taxes on those wages | $2,000 | Cost of services |
| Parts and materials fitted on jobs | $9,800 | Cost of services |
| Subcontracted electrician on one install | $4,500 | Cost of services |
| Dispatcher's salary | $3,600 | Overhead |
| Shop rent and utilities | $2,400 | Overhead |
| Scheduling and accounting software | $500 | Overhead |
Cost of services comes to $39,300, leaving $22,700 of gross profit — a 36.6% margin. That figure is a direct read on the firm's pricing and crew utilisation, and it's completely hidden if all seven rows share one account. Take it a level deeper with job costing and the same margin appears per job, which is usually where an owner discovers their busiest customer is their thinnest.
One honest distortion worth naming. A sole proprietor drawing from the business rather than paying themselves a wage never has their own labour hit the books, so the resulting margin flatters reality. Keep that in mind before pricing new work off it — our look at owner's draw versus salary explains why the two are recorded so differently.
Two Routes to the Same Figure
The formula defines what COGS is. Which route it takes into your ledger depends on the inventory system you run.
Periodic: count, then compute
Purchases accumulate in their own account all year and COGS stays untouched until stock is physically counted. One adjustment at the end produces the entire figure. It's inexpensive and it's blind — margin in March isn't knowable until December's count is finished.
With Copper Kettle's numbers, the year-end work runs in two moves alongside the rest of your closing entries:
| Account | Debit | Credit |
|---|---|---|
| Cost of Goods Sold | $224,000 | |
| Purchases (incl. inbound freight) | $224,000 | |
| Then restate inventory from $61,000 to the counted $73,000: | ||
| Inventory | $12,000 | |
| Cost of Goods Sold | $12,000 | |
Which nets to $224,000 − $12,000 = $212,000, exactly what the formula produced.
Perpetual: cost recorded sale by sale
Every sale generates two entries — revenue on one side, cost on the other — keeping inventory and COGS accurate at all times. A wholesale case that cost $148 sells for $265:
| Account | Debit | Credit |
|---|---|---|
| Accounts Receivable (or Cash) | $265 | |
| Sales Revenue | $265 | |
| Paired with the cost side: | ||
| Cost of Goods Sold | $148 | |
| Inventory | $148 | |
No cash appears in that second entry at all — $148 simply moves from asset to expense, which is the entirety of what recognising COGS means in double-entry bookkeeping. You still count stock annually, but the count now tests your records rather than generating them, and any difference between counted and recorded value is measurable shrinkage — something periodic inventory conceals inside COGS permanently.
Same Stock, Two Different Answers
One wrinkle catches people out. When the same item was bought at several prices, the formula has to know which units left. Buy 200 units at $18 in February and 200 more at $23 in August, sell 250, and COGS is $4,750 under FIFO or $5,500 under LIFO — from a single identical purchase history.
Three approaches are recognised: FIFO releases the oldest costs first, LIFO the newest (and is prohibited under IFRS), and weighted average blends them. Choose one, apply it consistently, and write down the choice. Our comparison of inventory costing methods runs all three across the same purchases and shows the effect on both profit and tax.
Where the Figure Goes Astray
- Coding stock purchases straight to COGS. Far and away the most frequent error. Buying inventory isn't spending — it's swapping cash for a different asset. Expense it on arrival and every restocking month looks dreadful while every selling-down month looks spectacular.
- Valuing closing stock at selling price. The count belongs at cost. Put $73,000 of coffee on the sheet at its $131,000 retail value and you've cut COGS by $58,000 and conjured profit from nothing.
- Outbound delivery hidden inside COGS. Customer shipping is a selling cost. Blended with product cost, margin starts tracking courier pricing rather than your own.
- Period cutoff slips. Stock received on the 30th but invoiced on the 3rd, or shipped on the 31st and counted anyway, drops the cost into the wrong month. The annual total survives; two months of reporting don't. Worth a line on the month-end close checklist.
- Never drawing the line at all. Common in service firms: one enormous Wages account below gross profit, and the statement can no longer say whether the work itself earns anything.
A Gross Margin You Don't Have to Rebuild Monthly
Kantivo carries Cost of Goods Sold as its own account type, so gross profit shows up as a genuine subtotal on every income statement instead of something you assemble in a spreadsheet afterwards. Perpetual inventory writes the cost entry as each sale posts, per-item costing supports FIFO, LIFO or weighted average, and the whole thing is GAAP-compliant double-entry accounting running on your own machine — one flat annual price, no monthly billing.
Start Free 30-Day Trial Try Live DemoReading the Margin You've Just Produced
What is a good gross profit margin?
Gross margin is gross profit over revenue — Copper Kettle's $183,000 against $395,000 gives 46.3%. No universal target exists, because the meaningful comparison is always within an industry: grocery retail operates in the teens, specialty retail frequently sits between 35% and 50%, professional services often above 50%. Measuring yourself against a business in a different sector produces nothing but noise.
Your own trajectory is the useful signal. Record gross margin as a percentage every month. A dependable 46% that erodes to 40% across two quarters is telling you something real — supplier increases you absorbed rather than passed on, discounting that crept into quotes, a mix shifting toward thinner products, or stock going missing. Each of those is far cheaper to address in month three than at year end. Gross margin appears alongside the rest in our rundown of financial ratios worth tracking.
In Short
Cost of goods sold is three figures and a subtraction; virtually all the difficulty lives in classification rather than arithmetic. Sort direct costs from overhead honestly, keep inbound and outbound freight on opposite sides of the gross profit line, value closing stock at what it cost you, and settle on one costing method. Do that and gross profit becomes the most informative line you own — the one that says whether what you sell earns money before overhead joins the conversation.
Prefer to learn the entries by doing them? Our free interactive double-entry accounting course lets you work through inventory and COGS postings in a sandbox, at whatever pace suits you.
Frequently Asked Questions
How do you work out cost of goods sold?
Take the inventory you opened the period with, add everything you bought during it, then subtract whatever remains at the end. A roaster opening at $61,000, buying $224,000 of green coffee and freight, and counting $73,000 in the warehouse on the final day has sold $212,000 of product at cost. Anything that was available and is no longer sitting there has been sold, so the subtraction is really just a stock reconciliation in accounting clothing. Producers replace the purchases figure with cost of goods manufactured.
Which costs count as cost of goods sold?
Anything spent specifically to obtain or produce the units that left your business. That covers what you paid the supplier, raw materials, inbound freight and customs duty, the pay of staff physically doing the production or the billable work, subcontractors hired for a job, and factory-level overhead such as plant rent and machinery depreciation. Costs that keep arriving whether or not you make a sale sit outside COGS: administration wages, advertising, office premises, insurance and general software.
Does freight go into cost of goods sold?
Inbound freight does; outbound freight does not. Money spent bringing stock to you is treated as part of that stock's cost, so it reaches the income statement as COGS at the moment the item is sold. Money spent delivering a finished order to a customer is a cost of selling, reported below gross profit alongside other operating expenses. One courier account can easily contain both, and separating them is worth the few minutes because otherwise your gross margin moves whenever your delivery volume does.
Can a service business have a cost of goods sold?
It can, and most should, usually recorded as cost of services or cost of revenue. For a firm selling expertise or labour, the direct costs are the payroll of whoever performs the billable work, any subcontracted specialists, materials consumed on the engagement, and licences bought for one particular project. Support roles, premises and firm-wide tools remain operating expenses. Drawing that line is what gives a service business a genuine gross margin, and with it an answer to whether the rates being charged actually work.
How is COGS different from an operating expense?
Volume is the difference. Direct costs rise and fall with how much you sell, while operating expenses largely hold steady no matter what the month looks like. Doubling output roughly doubles your materials bill, but the landlord and the bookkeeper charge the same either way. Imagining a month with zero sales is the quickest sorting test: whatever vanishes was direct, whatever still lands is overhead. Keeping them apart is what produces the gross profit subtotal, the figure that reveals whether the offering itself is viable before overhead is even counted.
Should you aim for a lower cost of goods sold?
As a proportion of revenue, lower is healthier, since more of every sale survives to cover fixed costs. Be sceptical of sudden improvements, though. A COGS percentage that drops sharply usually signals a bookkeeping problem rather than a commercial win: closing stock valued too generously, purchases coded to the wrong account, or invoices falling into the wrong period. Watch the percentage month by month rather than the dollar figure, and treat any move of several points as something to explain before you bank it.
Related Articles
- Inventory Costing Methods Compared: FIFO, LIFO and Weighted Average
- How to Read a Profit and Loss Statement
- Job Costing for Small Business: Finding the Work That Pays
- How to Categorize Business Expenses: A Small Business Guide
- 7 Financial Ratios Every Small Business Owner Should Track
- How to Set Up a Chart of Accounts for Small Business
- The Month-End Close Checklist for Small Business (8 Steps, In Order)
- Year-End Closing Entries: What Actually Happens When You Close the Books
One good accounting read a month
New bookkeeping walkthroughs land in your inbox as we write them — practical, written for owners, and never more than monthly.
Monthly at most. Every email carries a one-click opt-out.