Cost of Goods Sold Explained: COGS Formula, What's Included, and Gross Margin Impact
May 9, 2026 · guides · 11 min read
Cost of Goods Sold Explained: COGS Formula, What Is Included, and Gross Margin Impact
Cost of goods sold is the most important line item between a company's revenue and its gross profit. Every dollar of COGS reduces the money left over to pay for operations, taxes, debt service, and returns to investors. Understanding what belongs in COGS, how it is calculated, and what it signals about a business is foundational to reading any income statement.
This guide covers the COGS definition, the formula, what costs are included and excluded, how COGS differs by industry type, inventory valuation methods, the relationship between COGS and gross margin, how rising COGS compresses profitability, and worked examples across several business types.
What Is Cost of Goods Sold
Cost of goods sold, abbreviated as COGS, represents the direct costs incurred to produce the goods or services a company sold during a given accounting period. These are costs that would not have been incurred if those units had not been produced and sold.
COGS appears on the income statement directly below revenue. Subtract COGS from revenue and you get gross profit:
Revenue
- Cost of Goods Sold
= Gross Profit
COGS is a period-specific figure. It does not represent all costs of producing inventory held in the warehouse. It represents only the costs tied to inventory that was actually sold during the period. Unsold inventory remains on the balance sheet as a current asset until it is sold, at which point it flows through the income statement as COGS.
The COGS Formula
The standard COGS formula used in accounting is:
COGS = Beginning Inventory + Purchases During the Period - Ending Inventory
Breaking that down:
- Beginning Inventory is the value of unsold inventory carried over from the prior period.
- Purchases During the Period refers to the cost of additional raw materials, finished goods, or components acquired during the period. For manufacturers, this includes direct labor and overhead applied to production. For retailers, it is the cost of merchandise purchased for resale.
- Ending Inventory is the value of unsold inventory remaining at the close of the period, which is carried forward to the next period.
A worked example:
A retail hardware store starts the quarter with $80,000 in inventory, purchases $220,000 in new products, and ends the quarter with $65,000 remaining on the shelves.
COGS = $80,000 + $220,000 - $65,000 = $235,000
If the store generated $400,000 in revenue during the same quarter:
Gross Profit = $400,000 - $235,000 = $165,000
What Is Included in COGS
The costs included in COGS are direct costs, meaning costs that can be traced directly to the production or acquisition of the goods or services sold.
For a manufacturer, COGS typically includes:
- Raw materials consumed in production
- Direct labor paid to workers who physically produce the goods
- Manufacturing overhead that can be allocated to specific units, such as factory utilities, depreciation on production equipment, and quality control costs
- Inbound freight on materials arriving at the facility
- Packaging costs for the finished product
For a retailer, COGS typically includes:
- Cost of merchandise purchased from suppliers or wholesalers
- Inbound shipping and freight to receive the merchandise
- Import duties and tariffs on goods sourced internationally
- Direct warehouse labor tied to receiving and stocking inventory
For a restaurant or food service business, COGS typically includes:
- Food and beverage costs consumed in producing the meals served
- Kitchen supply costs directly tied to food preparation
What Is Excluded from COGS
COGS does not include indirect or period costs. These are called operating expenses and appear below the gross profit line on the income statement.
Costs excluded from COGS include:
- Sales and marketing expenses, including advertising, sales staff salaries, and promotional costs
- General and administrative expenses, including executive compensation, legal fees, accounting fees, and office rent
- Research and development costs
- Depreciation on non-production assets such as corporate offices
- Interest expense on debt
- Income taxes
- Outbound shipping costs paid to deliver goods to customers (these are often classified as selling expenses, not COGS, though accounting treatment varies)
The distinction between COGS and operating expenses matters because gross margin isolates production efficiency, while operating margin captures the full cost of running the business.
COGS by Industry Type
The composition of COGS varies significantly across industries. Comparing raw COGS figures across different business models without context is misleading.
Manufacturing Companies
Manufacturers tend to have high COGS relative to revenue because they purchase raw materials, employ production workers, and operate capital-intensive facilities. A steel producer, an automotive manufacturer, or a consumer electronics company will typically report COGS that consumes 60 to 80 percent of revenue, resulting in gross margins in the 20 to 40 percent range.
Example: An industrial equipment manufacturer reports $900 million in revenue. COGS includes $340 million in raw steel and components, $180 million in factory labor, and $60 million in manufacturing overhead applied to units sold. Total COGS is $580 million. Gross profit is $320 million, representing a 35.6 percent gross margin.
Retailers
Retailers purchase finished goods and resell them. Their COGS is primarily the wholesale cost of merchandise. A grocery chain or clothing retailer typically operates on thin gross margins, often 25 to 45 percent, because they are competing on price and convenience rather than production differentiation.
Example: A specialty apparel retailer reports $600 million in revenue. It paid $330 million to suppliers for the merchandise it sold, plus $18 million in freight and import costs. Total COGS is $348 million. Gross profit is $252 million, a 42 percent gross margin.
Service Companies
Traditional service businesses, such as consulting firms, law practices, or staffing agencies, often treat direct labor costs as their primary COGS component. A management consulting firm would include the salaries and benefits of billable consultants as COGS. Administrative staff, office overhead, and marketing budgets are excluded and classified as operating expenses.
Service companies can achieve higher gross margins than manufacturers or retailers because their production costs are largely labor, which scales more flexibly than physical inventory.
SaaS and Software Companies
Software-as-a-service companies have a different COGS profile than any other industry type. Because software can be replicated at near-zero marginal cost, the primary COGS components for SaaS businesses are:
- Cloud hosting and infrastructure costs tied to delivering the software to customers
- Customer support labor directly tied to servicing accounts
- Third-party data or API costs embedded in the product
- Amortization of capitalized software development costs, in some accounting frameworks
The variable cost of delivering one additional software subscription is far lower than manufacturing one additional physical unit. This is why mature SaaS companies routinely report gross margins of 70 to 85 percent, a structural advantage that is baked into their business model.
Example: A SaaS analytics platform reports $120 million in annual recurring revenue. Its COGS includes $14 million in cloud infrastructure, $7 million in customer support headcount, and $3 million in licensed third-party data. Total COGS is $24 million. Gross profit is $96 million, an 80 percent gross margin.
Inventory Valuation Methods and Their Effect on COGS
When a company holds inventory purchased at different prices over time, it must choose a method for determining which cost flows through COGS when a unit is sold. The choice of inventory valuation method directly affects reported COGS, gross profit, and taxes.
FIFO: First In, First Out
Under FIFO, the oldest inventory costs are assumed to be sold first. The cost of the earliest-purchased units flows through COGS, and the most recently acquired units remain in ending inventory.
In a rising-cost environment, FIFO produces lower COGS and higher gross profit because older, cheaper inventory is expensed first. This results in higher reported earnings but also higher income taxes. Ending inventory on the balance sheet reflects more current replacement costs.
Example: A food distributor holds 1,000 units. The first 600 were purchased at $10 each. The next 400 were purchased at $13 each. Under FIFO, if 700 units are sold, COGS is calculated as: 600 units at $10 ($6,000) plus 100 units at $13 ($1,300), totaling $7,300.
LIFO: Last In, First Out
Under LIFO, the most recently purchased inventory costs are assumed to be sold first. In a rising-cost environment, LIFO produces higher COGS and lower gross profit because the more expensive newer inventory is expensed first. This reduces reported earnings but also reduces income taxes, which is why some U.S. companies prefer LIFO as a tax strategy.
LIFO is only permitted under U.S. GAAP, not under IFRS. When comparing U.S. and international companies, inventory method differences can distort margin comparisons.
Using the same example: Under LIFO, 700 units sold means 400 units at $13 ($5,200) plus 300 units at $10 ($3,000), totaling $8,200. Gross profit is lower than under FIFO because the more expensive units were expensed first.
Weighted Average Cost
Under the weighted average cost method, a company calculates the average cost per unit across all inventory on hand, then applies that average cost to every unit sold and every unit remaining in ending inventory.
Weighted Average Cost Per Unit = Total Cost of Available Inventory / Total Units Available
Example: Using the same distributor with 600 units at $10 and 400 units at $13:
Total cost = ($10 x 600) + ($13 x 400) = $6,000 + $5,200 = $11,200
Total units = 1,000
Weighted average = $11,200 / 1,000 = $11.20 per unit
If 700 units are sold: COGS = 700 x $11.20 = $7,840.
Weighted average smooths out price fluctuations and is commonly used in industries where inventory is homogeneous and prices move gradually.
Gross Profit and Gross Margin
Gross profit is the dollar amount remaining after subtracting COGS from revenue. Gross margin expresses that as a percentage of revenue.
Gross Profit = Revenue - COGS
Gross Margin = Gross Profit / Revenue
Gross margin is one of the most important metrics for evaluating a company's pricing power, competitive position, and operational efficiency. A high gross margin indicates the company earns substantially more per dollar of revenue than it spends producing what it sells. A low gross margin indicates thin spread between production cost and selling price.
Gross margin varies widely by industry. A 30 percent gross margin in grocery retail is competitive. A 30 percent gross margin in enterprise software signals a structural problem. Approximate ranges by sector:
- Software and SaaS: 65 to 85 percent
- Pharmaceuticals: 55 to 75 percent
- Consumer staples: 25 to 45 percent
- Specialty retail: 35 to 50 percent
- Industrial manufacturing: 20 to 40 percent
- Grocery and food retail: 20 to 30 percent
- Automotive: 10 to 20 percent
How Rising COGS Compresses Margins
Gross margin compression occurs when COGS grows faster than revenue. This can happen for several reasons, and each carries different implications for the durability of a company's profitability.
Input cost inflation: If a company depends on raw materials such as steel, copper, lumber, agricultural commodities, or semiconductors, a sustained rise in those input prices raises COGS without any corresponding increase in revenue unless the company can pass costs to customers through higher prices.
Labor cost increases: For manufacturers and service companies with significant direct labor in COGS, wage inflation compresses margins. Tight labor markets add pressure on both hiring and retention.
Supply chain disruptions: Shipping rate spikes, port bottlenecks, and component shortages sharply increase COGS for companies dependent on global procurement. When ocean freight rates triple, COGS rises even if supplier prices hold flat.
Product mix shift: Selling proportionally more lower-margin products reduces reported gross margin even if individual product margins hold steady. This is common in consumer electronics during new product cycles.
Pricing pressure: In competitive markets, companies cannot always raise prices in response to cost increases. Retailers competing on price or vendors losing pricing leverage absorb the cost increase in gross margin rather than passing it to customers.
A worked example of margin compression:
A consumer goods company reported the following over two consecutive years:
Year 1:
- Revenue: $500 million
- COGS: $300 million
- Gross profit: $200 million
- Gross margin: 40 percent
Year 2 (with input cost inflation):
- Revenue: $510 million (2 percent increase from modest volume growth)
- COGS: $340 million (13 percent increase from raw material cost increases)
- Gross profit: $170 million
- Gross margin: 33.3 percent
Despite growing revenue, gross profit fell by $30 million and gross margin dropped 6.7 percentage points. This is margin compression in action. The company grew its top line but became significantly less profitable at the gross level.
COGS and Supply Chain Exposure
COGS is the clearest window into a company's supply chain exposure. A company with high COGS relative to revenue relies heavily on external suppliers and inputs to deliver its product. Geopolitical disruptions, currency fluctuations, tariff changes, and energy price spikes all flow directly into COGS before they affect any other line on the income statement.
Companies that source materials from diverse geographies or hold long-term fixed-price supply contracts tend to have more stable COGS trajectories. Companies with concentrated supply chains or heavy reliance on a single commodity face higher volatility. Investors often review notes to financial statements and management discussion sections in annual reports to understand sourcing exposure and hedging practices.
COGS vs Operating Expenses: Why the Distinction Matters
A common point of confusion is the difference between COGS and operating expenses (OpEx). Both reduce earnings, but they measure different aspects of a business.
COGS measures the cost of production. It is variable in the short run, meaning it tends to rise and fall with revenue. If a company sells more units, COGS typically rises proportionally.
Operating expenses measure the cost of running the business independent of production volume. They include sales and marketing, general and administrative costs, and research and development. These costs may be relatively fixed over a wide range of revenue, which creates operating leverage when revenue grows.
Separating COGS from OpEx allows analysts to distinguish between production efficiency (gross margin) and operating efficiency (operating margin). A company might have excellent gross margins but poor operating margins because of heavy spending on sales or administrative overhead. A company with thin gross margins might still achieve reasonable operating margins by running a lean cost structure.
A software company with 78 percent gross margins spending aggressively on sales is making a different trade-off than a retailer with 32 percent gross margins and a lean cost structure. That difference is only visible when COGS and operating expenses are analyzed separately.
Using COGS in Stock Research
COGS trends over time reveal important patterns in any financial statement analysis:
- Stable or declining COGS as a percentage of revenue suggests pricing power, improving efficiency, or favorable input cost dynamics.
- Rising COGS as a percentage of revenue points to input cost inflation, pricing pressure, product mix deterioration, or supply chain stress.
- COGS growing faster than revenue for multiple consecutive quarters is a warning of structural margin pressure, not a one-time event.
- Gross margin that diverges significantly from industry peers warrants investigation. Higher gross margins usually reflect a durable competitive advantage. Lower gross margins may signal commoditization or pricing weakness.
Tools that automate financial ratio tracking let investors benchmark COGS trends and gross margin trajectories across sectors, helping distinguish temporary compression from structural deterioration.
Summary: Key COGS Concepts
The COGS formula: Beginning Inventory + Purchases During the Period - Ending Inventory
What COGS includes: Raw materials, direct labor, manufacturing overhead allocated to units sold, and merchandise acquisition costs for retailers.
What COGS excludes: Sales and marketing, general and administrative costs, research and development, and interest expense.
Gross profit and gross margin: Revenue minus COGS equals gross profit. Gross margin equals gross profit divided by revenue.
Inventory methods: FIFO uses oldest costs first, producing lower COGS in rising price environments. LIFO uses newest costs first, producing higher COGS in rising price environments and is available only under U.S. GAAP. Weighted average smooths cost across all available units.
Gross margin by industry: SaaS and software companies typically achieve 65 to 85 percent gross margins. Manufacturers and retailers typically operate in the 20 to 45 percent range.
Margin compression: When input costs or supply chain costs rise faster than revenue, gross margin shrinks. Tracking this trend is one of the most practical applications of COGS analysis in fundamental research.
Cost of goods sold provides the foundation for every margin metric that follows on the income statement. Every profitability analysis starts with one question: how much did it cost to produce what was sold? COGS is the answer.