Cost of Goods Sold (COGS)

What is Cost of Goods Sold (COGS)?

Cost of goods sold (COGS) is the direct cost of producing the goods or delivering the services a company sells in a period. It is subtracted from revenue to calculate gross profit.

Updated November 2026 · 5 min read


Cost of goods sold, or COGS, is what it costs a company to produce what it sells. For a manufacturer, it includes raw materials, factory labor and production overhead. For a retailer, it is mainly the cost of the inventory sold. For a software or SaaS company, often called cost of revenue, it includes the hosting, infrastructure, third-party software and support costs needed to deliver the service to customers. COGS appears on the income statement directly below revenue.

COGS matters because it determines gross profit and gross margin, two of the most important measures of a business's economics. For technology leaders, COGS has become increasingly relevant as more companies sell digital products and services. Cloud hosting, AI model usage and customer-facing platforms often sit in COGS, which means IT and engineering decisions directly affect the gross margin that investors watch closely.

Definition of Cost of Goods Sold (COGS)

Cost of goods sold is the total of the direct costs attributable to the production or delivery of goods and services sold during a period. Revenue minus COGS equals gross profit, and gross profit divided by revenue equals gross margin.

COGS excludes operating expenses that are not directly tied to producing or delivering what is sold, such as sales and marketing, general administration and research and development. These appear below gross profit on the income statement.

COGS for Product Companies

For companies that sell physical goods, COGS typically includes direct materials, direct labor and manufacturing overhead, such as factory utilities and equipment depreciation. Under absorption costing, a share of fixed production overhead is included in the cost of each unit.

COGS for physical goods is closely linked to inventory. Costs are held in inventory on the balance sheet until the goods are sold, at which point they move to COGS. Inventory methods, such as first-in, first-out or weighted average, affect how much cost is recognized in each period.

Shipping to customers, warehousing and handling may be included in COGS or treated as operating expenses, depending on company policy and the nature of the business.

COGS for Software and SaaS Companies

For software and SaaS companies, COGS, often called cost of revenue, typically includes cloud hosting and infrastructure used to run the service, third-party software and data costs embedded in the product, customer support and onboarding, and amortization of capitalized software development that supports the product.

Development of new features is usually classified as research and development, not COGS, while the cost of keeping the service running for customers is classified as COGS. Where exactly the line falls varies between companies and should be applied consistently.

AI features add a new component. Model inference costs incurred to serve customers are typically part of COGS, and they can be significant, which is why AI-heavy products often have lower gross margins than traditional software.

Importance of COGS in IT Financial Management

For companies that deliver products or services through technology, a significant share of technology spending sits in COGS. That makes IT and engineering decisions part of the company's gross margin story.

It also means technology costs need to be classified carefully between COGS and operating expenses.

Investors and lenders often compare gross margins across similar companies, so changes in technology-driven COGS can affect how the business is valued.

Technology Costs and Gross Margin

Cloud hosting for customer-facing services, production databases, content delivery and AI inference all increase COGS as usage grows. If these costs grow faster than revenue, gross margin falls.

Tracking technology COGS per customer or per transaction, using unit economics, shows whether the platform is becoming more or less efficient as the business scales. Improving it directly improves gross margin.

Many SaaS companies set gross margin targets, and engineering teams increasingly share responsibility for meeting them through efficient architecture and cost-aware design.

Classification and Allocation

Many technology costs serve both customers and internal users. A cloud account might host the production product and internal tools, and a support team might help both customers and employees. These costs need to be split between COGS and operating expenses.

Clear rules, supported by tagging of cloud resources and cost allocation, ensure the split is accurate and consistent. Misclassification can distort gross margin and mislead investors and managers.

Auditors often review the basis for these allocations, so the rules and supporting data should be documented.

How to Manage Technology Costs in COGS

Managing technology costs in COGS involves accurate classification, unit cost tracking and optimization focused on the costs of serving customers.

Finance, engineering and IT finance teams need to work together, since engineering decisions drive most of these costs.

Accurate Classification

Organizations should define which technology costs belong in COGS, such as production hosting, customer support tooling and third-party services embedded in the product, and which belong in operating expenses, such as internal IT and development environments.

Separating production and non-production environments into different accounts or tags makes classification much easier and more reliable. Shared costs should be allocated using documented bases.

The classification should be reviewed when the product or architecture changes significantly, since new services can shift costs between categories.

Optimizing Cost of Revenue

Optimization of technology COGS focuses on the efficiency of serving customers: rightsizing infrastructure, using committed-use discounts for stable workloads, improving architecture, caching and optimizing AI usage.

Because these savings improve gross margin, they are often a priority for leadership. Tracking COGS per customer alongside revenue per customer shows how improvements translate into margin.

Pricing decisions also matter. Where a feature carries high COGS, such as heavy AI usage, pricing tiers or usage limits may be needed to protect margin.

Examples of COGS in IT Financial Management

The examples below show technology costs in COGS.

Both use illustrative figures.

In each, technology decisions changed gross margin directly.

Gross Margin for a SaaS Company

A SaaS company has annual revenue of $40 million. Its cost of revenue includes $5 million of cloud hosting, $2 million of third-party software embedded in the product and $3 million of customer support, a total of $10 million.

Gross profit is $30 million and gross margin is 75 percent. A cloud optimization program that reduces hosting costs by $1.2 million raises gross margin to 78 percent, a meaningful improvement for investors.

AI Features and Margin

The company launches an AI assistant included in its standard subscription. Inference costs reach $2.4 million in the first year, all in COGS, reducing gross margin by six percentage points.

The company introduces a premium tier for heavy AI users and optimizes prompts and model selection, reducing inference costs per user by 40 percent. Gross margin recovers most of the lost ground while the feature continues to grow. Inference costs are now tracked per customer alongside other variable costs, so the team can see early if margin starts to slip again.

Conclusion

Cost of goods sold is the direct cost of producing goods or delivering services sold in a period, subtracted from revenue to calculate gross profit. For software and SaaS companies, it includes hosting, embedded third-party software, support and similar costs of delivering the service.

In IT financial management, COGS links technology decisions to gross margin. Classifying costs accurately between COGS and operating expenses, tracking cost of revenue per customer and optimizing the cost of serving customers help organizations protect and improve their margins.