
- What is cost of goods sold (COGS)?
- Why COGS matters for your business
- The cost of goods sold formula
- How to calculate cost of goods sold step by step
- What is included in COGS?
- COGS accounting methods for inventory valuation
- Cost of goods sold vs. cost of sales
- COGS vs. operating expenses
- COGS examples for retail, manufacturing, and SaaS
- Tips for reducing COGS
- Common mistakes and limitations of COGS reporting
- How to analyze your cost of goods sold
- Automate COGS tracking with AI-powered coding

Cost of goods sold (COGS) is the total direct cost of producing or purchasing the goods you sell during an accounting period. You calculate it with a simple formula:
Beginning inventory + Purchases − Ending inventory = COGS
Accuracy matters here: COGS determines your gross profit, shapes pricing decisions, and directly reduces your taxable income.
What is cost of goods sold (COGS)?
COGS captures the direct cost of producing or acquiring the goods you sell. It includes raw materials, direct labor, and other expenses required to get products ready for sale.
On the income statement, COGS is the first expense line after revenue. Subtracting it from revenue gives you gross profit, which shows how efficiently you convert sales into earnings. For manufacturers, COGS includes raw materials and factory labor; for retailers, it's the wholesale cost of inventory sold.
Unlike overhead or administrative costs, which fall under selling, general, and administrative expenses (SG&A) or operating expenses (OpEx), COGS includes only expenses directly tied to production or resale.
Three components drive your COGS calculation:
- Beginning inventory: The value of inventory at the start of the period
- Purchases: The cost of new inventory acquired or produced during the period
- Ending inventory: The value of unsold inventory at period end
Understanding these components helps you price products accurately, manage inventory efficiently, and protect your margins.
Where COGS appears on the income statement
COGS is the first expense line item directly below revenue on the income statement. Revenue minus COGS equals gross profit, the starting point for every profitability metric that follows.
The income statement works like a waterfall: revenue flows in at the top, COGS is the first deduction, and the remaining gross profit covers operating expenses, taxes, and net income.
Why COGS matters for your business
COGS directly impacts your profitability, cash flow, and tax liability. Because it sits at the top of your income statement, even small changes can ripple through your margins.
Tracking COGS closely lets you price products confidently, control production costs, and protect gross profit. It also keeps your financial reporting accurate and prevents you from overpaying taxes.
COGS influences several core business decisions:
- Gross profit calculation: Revenue − COGS = Gross profit. Lower COGS improves gross margin and strengthens net income.
- Pricing decisions: Knowing your true product cost prevents you from selling at a loss and helps you maintain target margins
- Tax deductions: COGS reduces taxable income dollar for dollar. Accurate reporting supports compliance with generally accepted accounting principles (GAAP) and IRS rules.
The cost of goods sold formula
Cost of goods sold (COGS) is calculated using this formula:
Cost of goods sold (COGS) = Beginning inventory + Purchases − Ending inventory
In simple terms, you start with what you had, add what you bought or produced, and subtract what you still have left. The result is the total cost of the goods you actually sold during the period.
This formula works for retailers, manufacturers, and product-based businesses of any size.
Step-by-step COGS calculation example
Here's how the formula works in practice.
A clothing store starts the month with $10,000 in inventory. During the month, it purchases $15,000 more inventory. At month-end, $8,000 of inventory remains unsold.
Step 1: Add beginning inventory and purchases
$10,000 + $15,000 = $25,000
Step 2: Subtract ending inventory
$25,000 − $8,000 = $17,000
The store's cost of goods sold for the month is $17,000.
If revenue was $30,000:
Gross profit = Revenue − COGS
$30,000 − $17,000 = $13,000
How to calculate cost of goods sold step by step
Breaking the calculation into clear steps reduces errors and keeps your financial reporting consistent. Follow this process each accounting period:
1. Determine your beginning inventory
Start with the prior period's ending inventory balance. Pull the number from your balance sheet and inventory report, then reconcile it to the general ledger. Resolve any write-downs, shrinkage, or pending adjustments before moving forward.
2. Add purchases made during the period
Total all inventory purchases during the period, including freight-in. If you manufacture goods, include raw materials, direct labor, and manufacturing overhead. Exclude SG&A and other operating expenses to avoid understating COGS.
3. Subtract your ending inventory
Determine your ending inventory through a physical count or cycle counts and reconcile it to your perpetual records. Record any damaged or obsolete inventory write-downs before finalizing the balance.
To assign costs to remaining inventory, apply your chosen valuation method:
- First-in, first-out (FIFO)
- Last-in, first-out (LIFO)
- Weighted average
- Specific identification
Your method affects your financial statements, taxable income, and reported margins.
4. Apply the formula and verify results
Apply the formula:
COGS = Beginning inventory + Purchases − Ending inventory
Then, review the result against sales volume and historical gross margin trends.
If COGS looks unusually high or low, double-check cutoff timing, count accuracy, and valuation settings.
Quick checks
Before closing the books, run these verification steps:
- Confirm inventory decreases on the balance sheet align with COGS increases on the income statement
- Verify freight-in is included and freight-out is excluded
- Ensure direct production costs are in COGS and indirect costs remain in OpEx
Using the same process each period improves accuracy and keeps your COGS reporting audit-ready.
Periodic vs. perpetual inventory systems
Your inventory system determines how and when you calculate COGS. Businesses typically use either a periodic or perpetual inventory system.
- Under a periodic inventory system, you calculate COGS at the end of the accounting period using a physical inventory count. Inventory balances update only when you close the books
- Under a perpetual inventory system, inventory and COGS update continuously as transactions occur. Each sale automatically reduces inventory and records cost of goods sold in real time.
Perpetual systems provide better visibility and stronger internal controls, while periodic systems are simpler but rely more heavily on accurate physical counts.
For COGS accuracy, perpetual inventory tracking is the stronger choice; it catches shrinkage, spoilage, and miscounts in real time rather than waiting for a period-end physical count.
What is included in COGS?
COGS includes only direct costs required to produce or acquire the goods you sell. Operating expenses, such as marketing and administrative costs, remain separate on your income statement.
Direct materials
For retailers, this includes the wholesale cost of inventory. For manufacturers, it includes raw materials and components consumed in production. Freight-in charges to acquire materials also belong in COGS because they increase inventory value.
Direct labor
Direct labor includes wages for employees who physically produce goods, such as factory workers, assembly line staff, bakers, or machinists. These costs typically vary with production volume. Production-floor supervisors whose work directly supports manufacturing output may also qualify.
Manufacturing overhead
Manufacturing overhead includes production-related facility costs and indirect inputs necessary to create goods. Examples include factory rent, utilities that power equipment, machinery depreciation, quality control, maintenance, and essential packaging materials.
What's not included in COGS
COGS excludes costs that support general business operations rather than production. These costs appear in operating expenses or SG&A:
- Marketing and advertising expenses
- Sales team salaries and commissions
- Administrative and office staff wages
- Shipping to customers (freight-out)
- Office rent and insurance
- Professional services such as legal or accounting
If a cost exists only because you're producing or purchasing goods, it likely belongs in COGS. If it supports the business overall, it belongs in OpEx.
COGS accounting methods for inventory valuation
Your inventory valuation method directly affects how much cost flows into COGS and how much profit you report. The method you choose influences taxable income, gross margins, and how stakeholders interpret performance.
First-in, first-out (FIFO)
FIFO assumes the oldest inventory costs are sold first. In periods of rising prices, FIFO results in lower COGS and higher reported profits, which increases taxable income. FIFO is one of two methods permitted under International Financial Reporting Standards (IFRS), alongside weighted average cost. LIFO is prohibited under IFRS. FIFO works well for perishable or time-sensitive goods.
Last-in, first-out (LIFO)
LIFO assumes the newest inventory costs are sold first. During inflation, LIFO produces higher COGS and lower taxable income, reducing reported profits. LIFO is permitted under U.S. GAAP (ASC 330-10) but prohibited under IFRS (IAS 2). For tax rules governing inventory methods, see IRS Publication 538. The LIFO conformity requirement (IRC Section 472(c)) mandates that taxpayers electing LIFO for tax purposes must also use LIFO for financial reporting.
Weighted average cost method
The weighted average method blends all inventory costs into a single average unit cost. It smooths price fluctuations and produces more stable gross margins. This approach works well for businesses with high volumes of interchangeable items.
Specific identification method
Specific identification tracks the actual cost of each individual item sold. It provides the most precise COGS calculation but requires detailed recordkeeping. This method is best suited for high-value or unique products such as vehicles, jewelry, or custom equipment.
| Method | Best for | COGS impact (rising prices) |
|---|---|---|
| FIFO | Perishable goods, IFRS compliance | Lower COGS |
| LIFO | U.S. tax planning (GAAP only) | Higher COGS |
| Weighted average | Large volumes of similar items | Moderate COGS |
| Specific identification | Unique, high-value inventory | Varies by item |
Once you choose a valuation method, you must apply it consistently. Changing methods for tax purposes generally requires IRS consent under IRC Section 446(e), governed by IRS Rev. Proc. 2015-13 (as modified). Under GAAP (ASC 250-10), you must disclose the change, its justification, and cumulative effect.
Cost of goods sold vs. cost of sales
Cost of goods sold and cost of sales are often used interchangeably, but they're not always identical. COGS typically applies to product-based businesses that sell physical inventory, while cost of sales is a broader term that can include service delivery costs.
Product companies use COGS to capture inventory-related costs. Service businesses don't carry inventory, so they use cost of sales or cost of services to record direct labor and materials required to deliver services.
For example, a consulting firm may include consultant salaries and travel expenses in cost of sales. A manufacturer would include raw materials and factory labor in COGS. Some industries use the terms interchangeably, but consistency in classification matters more than terminology.
| Term | Typical industries | What it captures |
|---|---|---|
| Cost of goods sold (COGS) | Manufacturing, retail | Raw materials, direct labor, manufacturing overhead |
| Cost of sales | Services, consulting | Direct labor, materials, travel tied to client delivery |
| Cost of revenue | SaaS, tech | Hosting, infrastructure, support, and payment processing |
GAAP doesn't mandate a specific label for these line items. The choice between COGS, cost of sales, and cost of revenue reflects industry convention and what best describes the direct costs your business incurs to generate revenue.
COGS vs. operating expenses
COGS and operating expenses both appear on your income statement, but they measure different types of costs. COGS includes only direct costs tied to producing or acquiring goods for sale, while operating expenses cover indirect costs required to run your business.
This distinction directly affects gross margin. Misclassifying expenses between COGS and OpEx distorts profitability metrics and can lead to poor pricing or budgeting decisions.
| COGS | Operating expenses |
|---|---|
| Raw materials | Marketing and advertising |
| Direct labor (production workers) | Office salaries |
| Factory utilities | Rent (non-production facilities) |
| Production equipment depreciation | Software subscriptions |
| Freight-in | Freight-out |
If a cost varies with production or exists only because you sell goods, it likely belongs in COGS. If the cost supports overall operations regardless of output, it belongs in operating expenses.
COGS examples for retail, manufacturing, and SaaS
How COGS appears in your financials depends on your business model. The formula stays the same, but the costs that feed into it vary by industry.
Brick-and-mortar retail example
A clothing store starts the quarter with $50,000 in inventory. It purchases $120,000 in merchandise and pays $3,000 in freight-in. Ending inventory is $45,000.
COGS = $50,000 + $120,000 + $3,000 − $45,000 = $128,000
If sales total $250,000, gross profit equals $122,000. That produces a 48.8% gross margin ($122,000 / $250,000).
Light manufacturing example
A furniture manufacturer begins with $20,000 in raw materials. During the period, it purchases $40,000 in additional materials, incurs $30,000 in direct labor, and records $10,000 in manufacturing overhead. Ending raw materials and work-in-process total $15,000.
COGS = $20,000 + $40,000 + $30,000 + $10,000 − $15,000 = $85,000
This represents the total production cost of goods sold during the period.
SaaS example
Software-as-a-service (SaaS) companies don't hold physical inventory, but they still report costs directly tied to delivering their product as COGS. These may include hosting expenses, cloud infrastructure, customer support tied to service delivery, and engineering costs directly related to maintaining the platform.
For example, in 1 month a SaaS company incurs:
- Hosting costs: $1,000
- Engineer salaries tied to product delivery: $32,000
- Developer tools and infrastructure: $300
COGS = $1,000 + $32,000 + $300 = $33,300
Even without inventory, these direct delivery costs function as COGS because they scale with revenue and service usage.
SaaS COGS often also includes customer support salaries (when directly tied to service delivery), third-party API fees, and payment processing costs. On the income statement, SaaS companies typically label this line item "cost of revenue" rather than COGS, but it serves the same analytical function: measuring the direct costs required to deliver revenue.
Tips for reducing COGS
Lowering your cost of goods sold is one of the fastest ways to improve gross margin without raising prices. These four strategies target the direct costs that flow into COGS.
1. Negotiate supplier terms and volume discounts
Review your supplier contracts annually and benchmark pricing against competitors. Consolidating purchases with fewer vendors or committing to higher volumes can unlock 5–10% savings on materials. Because these are direct costs, every dollar you save flows straight to your gross profit line.
2. Reduce waste and inventory shrinkage
Spoilage, theft, and counting errors quietly inflate COGS. Implement cycle counts and real-time inventory tracking to catch discrepancies before they hit your financial statements. Even reducing shrinkage by 1–2% of inventory value can meaningfully improve margins over a full year.
3. Optimize production processes
Lean manufacturing principles help you produce more units per labor hour without sacrificing quality. Map your production workflow to identify bottlenecks, redundant steps, and idle time. Reducing direct labor hours per unit lowers COGS while maintaining output.
4. Use technology to automate COGS tracking
Manual expense classification increases the risk of miscategorizing costs between COGS and operating expenses. Automated accounting tools flag capitalization vs. expensing errors in real time, keeping your COGS accurate and your financial statements audit-ready.
Common mistakes and limitations of COGS reporting
Accurate COGS reporting is essential for reliable financial statements and tax compliance. Even small classification or timing errors can distort gross profit and mislead decision-making.
Common mistakes include:
- Including indirect costs: Administrative salaries, marketing spend, or other SG&A expenses incorrectly recorded as COGS. For example, if you misclassify $100,000 in office salaries as COGS, you overstate COGS by that amount and understate gross margin.
- Missing freight-in or supplier invoices: Understating inventory value can distort both COGS and gross margin. If you book $50,000 in freight-in as OpEx instead of COGS, you understate COGS by $50,000 and overstate gross margin.
- Cutoff errors: Inventory counts that don't align with the accounting period shift expenses into the wrong month or quarter. A $30,000 inventory receipt recorded 1 day late can inflate the current period's ending inventory and understate COGS.
- Inconsistent valuation methods: Switching between FIFO, LIFO, and weighted average without approval undermines comparability. A mid-year switch from FIFO to LIFO during rising prices could reduce reported profits by thousands, triggering audit flags and potential restatement.
- Ignoring shrinkage or obsolescence: Failing to record write-downs overstates ending inventory and understates COGS. If $20,000 in damaged goods sits in your inventory without a write-down, your COGS is understated by that amount and gross profit is artificially inflated.
Even when calculated correctly, COGS has limitations. It measures only direct production or acquisition costs, not total profitability.
- COGS excludes customer acquisition, research and development, and other indirect costs
- Gross margin alone won't show product-level profitability once you allocate overhead costs
- You need to evaluate COGS alongside OpEx, SG&A, and cash flow metrics to see the full financial picture
COGS is also a backward-looking metric that reflects historical costs, not current replacement costs. If supplier prices have shifted since your last inventory purchase, your reported COGS may not reflect what it would cost to restock today. Contextualize COGS trends alongside current supplier pricing when making forward-looking decisions.
Consistent accounting policies, periodic inventory audits, and trend analysis help reduce errors and improve decision-making.
How to analyze your cost of goods sold
Analyzing COGS helps you spot margin pressure early and make better pricing, purchasing, and operational decisions. Looking at the raw number isn't enough; you need context and trends.
Focus on these core metrics:
COGS margin
COGS margin = COGS / Revenue
This shows how much of every revenue dollar goes toward direct production costs. A rising percentage may signal supplier price increases, inefficiencies, or discounting pressure.
Gross margin
Gross margin = (Revenue − COGS) / Revenue
Higher gross margin reflects stronger cost control and pricing power. Track this by product line to identify your most and least profitable offerings.
Industry benchmarks can help you gauge where you stand. According to Damodaran's Margins by Sector data (NYU Stern, January 2026), typical gross margins vary widely by sector:
| Industry | Gross margin |
|---|---|
| Retail (general) | ~33% |
| Retail (grocery/food) | ~26% |
| Manufacturing (auto/truck) | ~10% |
| Manufacturing (furniture) | ~30% |
| Software (system and application) | ~72% |
| Software (internet) | ~63% |
| Food processing | ~23% |
| Food wholesalers | ~15% |
If your gross margin falls well below your sector average, your COGS may be running higher than competitors'. That gap points to concrete next steps: renegotiating supplier terms, cutting waste, or reducing labor hours per unit.
Inventory turnover
Inventory turnover = COGS / Average inventory
This measures how efficiently you convert inventory into sales. Higher turnover generally improves cash flow and reduces carrying costs.
Trend analysis
Compare COGS across months, quarters, and years. Sudden increases may indicate waste, shrinkage, production inefficiencies, or vendor price hikes. Consistent monitoring helps you act before margins erode.
Reviewing these metrics together shows you where margin pressure is coming from, whether that's rising supplier costs, excess inventory, or inefficient production.
Automate COGS tracking with AI-powered coding
Calculating COGS accurately requires tracking every purchase, labor cost, and overhead expense tied to production, a process that's time-consuming and error-prone when done manually. Misclassified transactions can distort your gross margin, throw off inventory valuations, and create compliance headaches during audits.
Ramp's AI-powered accounting software eliminates manual COGS tracking by coding every transaction in real time across all required fields. The platform learns your accounting patterns and applies your feedback to categorize transactions automatically as they post. You'll see COGS-related spend coded correctly from day one, with AI that flags only the exceptions that need human review.
Here's how Ramp streamlines COGS management:
- AI codes transactions instantly: Ramp applies your chart of accounts and coding rules to categorize COGS components as transactions occur
- Auto-sync routine spend: Ramp identifies in-policy COGS transactions and syncs them to your ERP automatically, so your inventory and expense accounts stay current without manual data entry
- Review with full context: Every transaction includes receipts, approvals, and vendor details in one place, so you can verify COGS classifications quickly and adjust as needed
- Track by project or product: Use custom fields and tags to allocate COGS to specific products, jobs, or cost centers, giving you granular visibility into profitability
Try an interactive demo to see how Ramp automates COGS tracking and helps finance teams close their books faster every month.

FAQs
COGS is calculated using the formula: Beginning Inventory + Purchases During the Period − Ending Inventory = COGS. For example, if you start with $10,000 in inventory, purchase $5,000 more, and end with $3,000, your COGS is $12,000.
COGS covers direct costs tied to producing goods sold — materials, labor, and manufacturing overhead. Operating expenses are indirect costs of running the business, like administrative salaries, rent, and marketing. COGS appears above the gross profit line on the income statement; operating expenses appear below it.
COGS is recorded as a debit on the income statement. When goods are sold, you debit the COGS account and credit inventory, which reduces the asset balance. This reflects costs being recognized as an expense at the moment of sale.
COGS appears on the income statement, not the balance sheet. It is listed as the first major expense line, directly below revenue. Revenue minus COGS equals gross profit. Unsold inventory, however, appears on the balance sheet as a current asset.
Yes. Service businesses can have COGS, though the terms 'cost of sales' or 'cost of revenue' are more common. For a consulting firm, cost of sales includes direct labor billed to clients. For a SaaS company, it includes hosting, infrastructure, and customer support tied to service delivery.
“Most banks treat the back office as a cost to keep down. We treat ours as a return to compound, which is why we run it on Ramp. Now we put our clients on Ramp, too.”
Patrick Gaughen
President & COO, Hingham Institution for Savings

“Browserbase builds infrastructure so AI agents can do real work. Ramp is doing the same for finance. It’s not another tool. It’s a system purpose-built for AI-driven finance, and that’s why we chose Ramp as our financial operating system from day one.”
Paul Klein IV
Founder & CEO, Browserbase

“We used to pay up to $20k a year for our AP platform. With Ramp, we’re earning back well over that amount. That's money that belongs to the mission now, not to the back-office software.”
Heidi Coffer
Chief Financial Officer, Boys & Girls Clubs of San Francisco

“The tricky thing about corporate travel policy is timing. We didn't need a stricter policy. We needed the policy to show up earlier. With Ramp Travel, it finally does.”
Keith Frantz
Director of Enterprise Risk Management, Prosper

“We're accountable to our funders, our partners, and the families we serve. That accountability starts with how we manage every dollar. Ramp makes it easy for our team to spend wisely, track in real time, and keep overhead low so more resources reach the families navigating infertility.”
Rachel Fruchtman
CFO, Jewish Fertility Foundation

“Each member of our team has an outsized impact due to our focus on using high-leverage tools like Ramp.”
Lauren Feeney
Controller, Perplexity

“With Ramp, we haven’t had to add accounting headcount to keep up with growth. The biggest takeaway is that instead of hiring our way through it, we fixed the workflow so we can keep supporting the organization as we scale.”
Melissa M.
VP of Accounting at Brandt Information Services

“In the public sector, every hour and every dollar belongs to the taxpayer. We can't afford to waste either. Ramp ensures we don't.”
Carly Ching
Finance Specialist, City of Ketchum



