Guides
Cost of Goods Sold (COGS): Formula and How to Calculate It
Cost of goods sold (COGS) is the direct cost of producing or buying the goods a company sold during a period. The core formula is COGS = Beginning Inventory + Purchases – Ending Inventory. It appears near the top of the income statement, directly below revenue, and subtracting it from revenue gives gross profit. For inventory-based businesses, COGS is usually the largest single expense line.
COGS captures only the costs tied to units that actually left the shelf: materials, direct labor, freight-in, and manufacturing overhead allocated to those units. Costs of goods still sitting in inventory stay on the balance sheet until sold. That timing distinction is why COGS is calculated from inventory balances rather than from a simple tally of what you spent.
The COGS formula
COGS = Beginning Inventory + Purchases – Ending Inventory. Start with the inventory value carried in from the prior period, add everything bought or produced during the current period, then subtract what remains unsold at period end. The result is the cost of the units sold. Purchases include freight-in and are reduced by returns and trade discounts.
The logic is a flow. Goods available for sale equals beginning inventory plus purchases. Whatever is not still in ending inventory must have been sold, so the difference is COGS. This avoids trying to track every individual sale and instead reconciles the two inventory counts.
Each input has a source. Beginning inventory equals last period’s ending inventory. Purchases come from supplier invoices plus freight-in. Ending inventory comes from a physical count or a perpetual system, valued under the company’s cost-flow method (FIFO, LIFO, or weighted average). A miscount at either end distorts COGS dollar for dollar.
What counts as a direct cost
Direct costs are the expenses that scale with units produced or bought: raw materials, direct labor on the production line, freight-in on inbound goods, and factory overhead allocated to units (utilities for the plant, equipment depreciation, supervisor wages). A service or software firm with no physical inventory may report “cost of revenue” or “cost of services” instead, covering hosting, support staff, and delivery labor.
Excluded from COGS: selling costs, marketing, office rent, administrative salaries, interest, and income tax. Those are period costs expensed as incurred, not attached to units. Section 263A (UNICAP) rules can require some indirect costs to be capitalized into inventory for tax purposes, which shifts them into COGS as the goods sell. See our guide to Section 263A uniform capitalization rules for how that allocation works.
Worked example: calculating COGS
A retailer starts the quarter with $40,000 of inventory, buys $110,000 more (including $3,000 freight-in), and counts $35,000 of inventory at quarter end. COGS = $40,000 + $110,000 – $35,000 = $115,000. If sales were $190,000, gross profit is $75,000 and gross margin is about 39%.
| Line item | Amount |
|---|---|
| Beginning inventory | $40,000 |
| Plus: Purchases (incl. $3,000 freight-in) | $110,000 |
| Goods available for sale | $150,000 |
| Less: Ending inventory | ($35,000) |
| Cost of goods sold | $115,000 |
| Sales revenue | $190,000 |
| Gross profit | $75,000 |
The check works in both directions. Goods available for sale ($150,000) split into what sold ($115,000) and what remained ($35,000). If the ending count came in at $30,000 instead, COGS would rise to $120,000 and gross profit would drop to $70,000, showing how sensitive the number is to the inventory count.
COGS vs operating expenses
COGS covers direct costs tied to units sold; operating expenses (OpEx) cover the indirect costs of running the business, such as marketing, rent, salaries for non-production staff, and administrative overhead. COGS sits above the gross profit line; OpEx sits below it. Only COGS reduces gross profit, while OpEx reduces operating income (and net income) further down.
The placement matters because the two lines answer different questions. Gross profit (revenue minus COGS) shows whether the product itself is profitable before overhead. Operating income (gross profit minus OpEx) shows whether the whole operation is profitable. A product can carry a healthy gross margin yet still lose money if OpEx is too heavy.
| Factor | COGS | Operating expenses |
|---|---|---|
| Nature | Direct, tied to units sold | Indirect, running the business |
| Examples | Materials, direct labor, freight-in, factory overhead | Marketing, rent, admin salaries, R&D |
| Income statement position | Above gross profit | Below gross profit |
| Scales with | Sales volume | More fixed over time |
| Affects | Gross profit | Operating and net income |
Misclassifying costs distorts margins. Pushing a delivery-driver wage into OpEx when it belongs in COGS inflates gross margin and can mislead investors comparing you to peers. Consistent classification, period to period, keeps the comparison honest. For the full walk from revenue down to net income, see how to read an income statement.
How COGS drives gross profit
Gross profit = Revenue – COGS, and gross margin = Gross profit / Revenue. Because COGS is often the largest expense, small shifts in it move gross profit sharply. A retailer with $190,000 in sales and $115,000 COGS earns $75,000 gross profit (about 39% margin); cutting COGS by $10,000 through better sourcing lifts gross profit to $85,000 without selling a single extra unit.
Gross margin is a core comparison metric. Analysts track it across quarters and against competitors to gauge pricing power and cost control. A declining margin can signal rising input costs, discounting, or an unfavorable product mix. Because COGS feeds directly into this figure, the cost-flow method a company picks can change the story even when nothing physical changed.
FIFO vs LIFO impact on COGS
The cost-flow assumption decides which unit costs move to COGS first. FIFO (first-in, first-out) sends the oldest costs to COGS. LIFO (last-in, first-out) sends the newest costs to COGS. When prices are rising, FIFO produces a lower COGS and higher gross profit, while LIFO produces a higher COGS and lower gross profit (and lower taxable income). Weighted average blends all unit costs together.
Consider buying 100 units at $10 in January and 100 units at $14 in June, then selling 100 units. Under FIFO, COGS uses the $10 units, so COGS is $1,000. Under LIFO, COGS uses the $14 units, so COGS is $1,400. Weighted average uses $12 per unit, so COGS is $1,200. Same sale, three different COGS figures purely from the method chosen.
| Method | COGS on 100 units sold | Ending inventory (100 units) | Effect in rising prices |
|---|---|---|---|
| FIFO | $1,000 (oldest cost) | $1,400 | Higher gross profit, higher tax |
| LIFO | $1,400 (newest cost) | $1,000 | Lower gross profit, lower tax |
| Weighted average | $1,200 (blended) | $1,200 | Between the two |
LIFO carries U.S.-specific rules. It is not permitted under IFRS, so multinational filers often cannot use it. Under the LIFO conformity rule (IRC Section 472(c)), a company that uses LIFO for tax generally must also use it in its financial statements shown to owners and creditors. LIFO can reduce taxable income when costs rise, but it leaves older, understated costs sitting in ending inventory on the balance sheet. Switching methods generally requires IRS consent via Form 3115, change in accounting method.
Where COGS is reported
Businesses report COGS on their tax returns and financial statements. Sole proprietors compute it in Part III of Schedule C (Form 1040). C corporations and many other entities use Form 1125-A, Cost of Goods Sold. On GAAP financial statements, COGS (or “cost of revenue”) appears as the first expense line under revenue, and the resulting gross profit is a required subtotal for many public filers.
The number connects to other statements too. Ending inventory flows to the balance sheet as a current asset. Purchases tie back to accounts payable and cash flow. Because inventory and COGS are linked, an inventory write-down for obsolete or damaged goods increases COGS in the period the write-down is recorded.
Frequently asked questions
What is included in cost of goods sold?
COGS includes the direct costs of the goods sold during the period: raw materials, direct labor, freight-in on inbound inventory, and manufacturing overhead allocated to units (such as factory utilities and equipment depreciation). It excludes selling, marketing, administrative, interest, and tax costs, which are period expenses reported separately below gross profit on the income statement.
Is cost of goods sold an expense?
Yes, COGS is an expense, but a specific kind. It is the expensed cost of inventory once the goods are sold, matched against the revenue they generated. Until units sell, their cost sits on the balance sheet as inventory (an asset). COGS is reported above the gross profit line, separate from operating expenses like rent and salaries.
How do you calculate COGS with the formula?
Use COGS = Beginning Inventory + Purchases – Ending Inventory. Take the prior period’s ending inventory as your beginning figure, add purchases and freight-in made during the period, then subtract the inventory value counted at period end. The remainder is the cost of what sold. Accurate physical counts at both ends are essential, since errors change COGS dollar for dollar.
Does FIFO or LIFO give a higher COGS?
When prices are rising, LIFO gives a higher COGS because it charges the newest, more expensive costs against sales first, which lowers gross profit and taxable income. FIFO gives a lower COGS by using the oldest, cheaper costs first, raising reported profit. When prices are falling, the effect reverses. Weighted average lands between the two.
What is the difference between COGS and gross profit?
COGS is the direct cost of goods sold; gross profit is what remains after subtracting COGS from revenue (Gross Profit = Revenue – COGS). COGS is an expense line, and gross profit is the subtotal it produces. Gross margin (gross profit divided by revenue) measures how much of each sales dollar survives after direct product costs, before operating expenses.
Can a service business have COGS?
Yes, though many report it as “cost of revenue” or “cost of services.” A service or software firm without physical inventory can include hosting costs, direct delivery labor, and support staff tied to serving customers. The principle is the same: costs that scale directly with delivering the sold service belong in this line, while general overhead stays in operating expenses.
Reviewed by The Ledgerism Editorial Team. Last reviewed: July 2026.