February 20, 2026

How to calculate cost of goods sold (COGS)

Explore this topicOpen ChatGPT

Cost of goods sold (COGS) is the total direct cost of producing or purchasing the goods you sell during an accounting period. You calculate COGS using this formula:

Cost of goods sold (COGS) = Beginning inventory + Purchases − Ending inventory

Because COGS sits directly below revenue on your income statement, it determines your gross profit and affects pricing, margins, and taxable income.

What is cost of goods sold (COGS)?

Cost of goods sold (COGS) is the total direct cost of producing or acquiring the goods you sell during a given period. 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.

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.

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 required under International Financial Reporting Standards (IFRS) and 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 but not allowed under IFRS.

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.

MethodBest forCOGS impact (rising prices)
FIFOPerishable goods, IFRS complianceLower COGS
LIFOU.S. tax planning (GAAP only)Higher COGS
Weighted averageLarge volumes of similar itemsModerate COGS
Specific identificationUnique, high-value inventoryVaries by item

Once you choose a valuation method, you must apply it consistently. Changing methods typically requires IRS approval and clear financial disclosure.

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.

COGSOperating expenses
Raw materialsMarketing and advertising
Direct labor (production workers)Office salaries
Factory utilitiesRent (non-production facilities)
Production equipment depreciationSoftware subscriptions
Freight-inFreight-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.

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.

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 significantly affect your margins.

Understanding and managing COGS allows you to price products confidently, control production costs, and protect gross profit. It also ensures accurate financial reporting and prevents 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
  • Performance tracking: Monitoring COGS trends helps you identify cost increases early and adjust pricing or suppliers
  • Cash flow management: You often pay suppliers before you collect revenue, so inefficient inventory management can strain working capital

Managing COGS effectively keeps margins healthy, cash flow stable, and financial statements reliable.

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.

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.

When you review these metrics together, you gain a clearer picture of operational efficiency, pricing health, and working capital performance.

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 one 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.

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
  • Missing freight-in or supplier invoices: Understating inventory value can distort both COGS and gross margin
  • Cutoff errors: Inventory counts that don’t align with the accounting period shift expenses into the wrong month or quarter
  • Inconsistent valuation methods: Switching between FIFO, LIFO, and weighted average without approval undermines comparability
  • Ignoring shrinkage or obsolescence: Failing to record write-downs overstates ending inventory and understates COGS

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

Consistent accounting policies, periodic inventory audits, and trend analysis help reduce errors and improve decision-making.

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 clear their accounting queue 3x faster every month.

Try Ramp for free
Share with
Tim StobierskiContributor Finance Writer
Tim Stobierski is a writer and content strategist focused on the world of finance, investing, software, and other complicated topics. His friends know him as a bit of a nerd. On the side, he writes poetry; his first book of poems, Dancehall, was published by Antrim House Books in July 2023.
Ramp is dedicated to helping businesses of all sizes make informed decisions. We adhere to strict editorial guidelines to ensure that our content meets and maintains our high standards.

FAQs

Only salaries for employees directly involved in producing goods are included in COGS. Administrative, sales, and executive salaries are classified as operating expenses.

Higher ending inventory lowers COGS because fewer goods were sold during the period. Lower ending inventory increases COGS because more inventory moved to cost of sales.

Service businesses typically report cost of sales or cost of services instead of COGS. These include direct labor and materials tied to service delivery but not physical inventory.

Incorrect COGS distorts gross profit, affects taxable income, and can lead to poor pricing decisions. Consistent inventory tracking and valuation methods help prevent these issues.

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

City of Ketchum

Ramp gives us one structured intake, one set of guardrails, and clean data end‑to‑end— that’s how we save 20 hours/month and buy back days at close.

David Eckstein

CFO, Vanta

How Vanta runs finance on Ramp with programmatic spend for 3 days faster close

Ramp is the only vendor that can service all of our employees across the globe in one unified system. They handle multiple currencies seamlessly, integrate with all of our accounting systems, and thanks to their customizable card and policy controls, we're compliant worldwide.

Brandon Zell

Chief Accounting Officer, Notion

How Notion unified global spend management across 10+ countries

When our teams need something, they usually need it right away. The more time we can save doing all those tedious tasks, the more time we can dedicate to supporting our student-athletes.

Sarah Harris

Secretary, The University of Tennessee Athletics Foundation, Inc.

How Tennessee built a championship-caliber back office with Ramp

Ramp had everything we were looking for, and even things we weren't looking for. The policy aspects, that's something I never even dreamed of that a purchasing card program could handle.

Doug Volesky

Director of Finance, City of Mount Vernon

City of Mount Vernon addresses budget constraints by blocking non-compliant spend, earning cash back with Ramp

Switching from Brex to Ramp wasn't just a platform swap—it was a strategic upgrade that aligned with our mission to be agile, efficient, and financially savvy.

Lily Liu

CEO, Piñata

How Piñata halved its finance team’s workload after moving from Brex to Ramp

With Ramp, everything lives in one place. You can click into a vendor and see every transaction, invoice, and contract. That didn't exist in Zip. It's made approvals much faster because decision-makers aren't chasing down information—they have it all at their fingertips.

Ryan Williams

Manager, Contract and Vendor Management, Advisor360°

How Advisor360° cut their intake-to-pay cycle by 50%

The ability to create flexible parameters, such as allowing bookings up to 25% above market rate, has been really good for us. Plus, having all the information within the same platform is really valuable.

Caroline Hill

Assistant Controller, Sana Benefits

How Sana Benefits improved control over T&E spend with Ramp Travel