Cost of goods sold (COGS) is more than an accounting term—it's a critical metric that directly measures your business's production costs and impacts your profitability. Understanding and calculating it correctly is essential for smart pricing, efficient inventory management, and accurate tax reporting.
While the COGS formula might look technical and intimidating, this guide will walk you through what's included in COGS, how to calculate it, and different ways to help prepare for tax season.
What is the cost of goods sold?
Cost of goods sold is the direct cost of producing products that your business sells. Also referred to as “cost of sales,” COGS includes the cost of materials and labor directly related to the production of retail products.
- COGS differs from operating expenses, which include costs like rent, utilities, and marketing, and from cost of revenue, which includes order fulfillment and payment processing.
- Retailers use different methods to calculate inventory costs, including FIFO (first-in, first-out), LIFO (last-in, first-out), and weighted average cost. These impact profitability and tax liability.
- Tracking COGS helps businesses set competitive pricing, manage inventory efficiently, and reduce taxable income by deducting production-related expenses.
What is the COGS formula?
The cost of goods sold formula is:
(Beginning inventory + purchases) – ending inventory = COGS

What’s included in the cost-of-goods-sold calculation?
The cost of goods sold is essentially the wholesale price of each item, which includes the direct labor costs incurred to produce each product.
This includes the costs of:
- All parts used to build or assemble the products
- Raw materials needed for the products
- Items purchased for resale and/or to create the product
- Parts or machines required to create the product
- Supplies required in the production of the product
- The people who put the products together and ship the parts
- Shipping parts and equipment to the warehouse to create the product, including containers, freight, and fuel surcharges
How COGS differs from other business expenses
COGS vs. operating expenses (OpEx)
Operating expenses (OpEx) and COGS are both subtracted from revenue, but they tell different stories about your company's performance.
Here’s how to distinguish them:
- COGS represents the direct costs of producing the goods you sell. These are considered variable costs because they fluctuate directly with your production volume.
- OpEx represents the indirect costs required to run your business, regardless of how much you sell. These are considered fixed costs and include expenses like rent, administrative salaries, and marketing.
This distinction is crucial on your income statement. Revenue minus COGS gives you your gross profit, which shows how efficiently you produce and price your goods.
First calculate gross profit, then subtract OpEx to find your operating profit, which reflects the business's overall profitability from its core operations.
For example, a fashion boutique must pay rent, utilities, and marketing costs no matter how many items it sells in a month. When the boutique sells a shirt, the COGS formula accounts for the sewing, the thread, the hanger, the tags, the packaging, and so on. It also includes any goods bought from suppliers and manufacturers.
COGS vs. cost of revenue
Cost of revenue includes all costs directly tied to generating sales, including COGS plus additional expenses such as:
- Order fulfillment and shipping to customers
- Payment processing fees
- Customer service and support expenses
- Website hosting and transaction platform fees
Unlike COGS, cost of revenue is used by businesses whose offerings extend beyond physical products. For example, a software-as-a-service (SaaS) company doesn’t have goods, so its cost of revenue includes server hosting costs, data center expenses, and salaries for front-line customer support staff needed to keep the service running.
How to calculate cost of goods sold: A five-step guide
- Determine direct costs vs. indirect costs
- Choose an inventory valuation method
- Calculate beginning inventory and cost of purchases
- Calculate ending inventory
- Apply the COGS formula
1. Determine direct costs vs. indirect costs
Direct costs are all sales costs directly associated with the product itself. This includes:
- Raw material costs or items for resale
- Inventory costs for the finished goods
- Supplies for the production of the products
- Packaging costs and work in process
- Supplies for production
- Overhead costs, including utilities and rent
Indirect expenses include:
- Labor, the people who put the product together
- The equipment used to manufacture the product
- Depreciation costs of the equipment
- Costs to store the products
- Administrative expenses and salaries
- Non-production equipment for back-office staff
A note on facilities costs: This part is tricky and requires an experienced accountant to accurately assign each product. These costs need to be divided strategically among all the products being manufactured and warehoused, and are usually calculated annually.
2. Choose an inventory valuation method (FIFO, LIFO, or weighted average)
Whoever prepares your taxes should advise you on what inventory accounting method you should use for your business. The most popular inventory valuation methods are:
FIFO method
First in, first out (FIFO) is when assets produced or purchased first are sold first. This method is best for perishables and products with a short shelf life. When prices rise, FIFO results in a lower COGS (since you’re selling older stock first) which increases your net income. When prices are decreasing, the opposite is true: COGS is higher, and net income is lower.
LIFO method
The last in, first out (LIFO) method assumes the goods you purchased or produced last are the first items you sold. When prices rise, goods with higher costs are sold first, and the closing inventory is lower. This results in a decreasing net income. During times of inflation, LIFO leads to a higher reported COGS on your financial statements and lower taxable income.
Weighted average cost method
In the weighted average cost method, the average price of all products in stock is used to value the goods sold, regardless of purchase date. It’s an ideal method for mass-produced items, such as water bottles or nails. To find the weighted average cost COGS, multiply the units sold by the average cost.
3. Determine your beginning inventory and purchases
Whether you sell jam, t-shirts, or digital downloads, you’ll need to know how much inventory you start the year with to calculate the cost of goods sold. Total of all the products purchased during the fiscal year that are available to sell, including raw materials, minus anything taken for personal use.
Beginning inventory doesn’t simply include finished products in stock and ready for resale, but also all the raw materials you have, any items that have been started but not completed, and any supplies. This should match the ending inventory for the previous fiscal year.
Further, whatever items and inventory are purchased throughout the year that don't fall under the beginning or ending inventory must also be accounted for.
- For a retailer, this is the cost of purchases.
- For a business that produces its own items, this is calculated as the cost of goods manufactured (COGM), a distinct calculation that includes all direct production expenses.
As with your taxes, you must keep all paperwork showing these items were purchased during the correct fiscal year.
4. Calculate your ending inventory
At the end of the year, take stock of all the remaining inventory—this means all products that remain and have not been sold. This information will be used in the current COGS calculation and will also be required for the following year's calculations.
All ending inventory can be categorized as one of the following:
- Resale-ready
- Damaged (requires the estimated value of the items damaged)
- Worthless products (evidence of destruction must be provided)
- Obsolete items (evidence of devaluation needed; these products can be donated to charities if still usable)
5. Apply the COGS formula
Once you’ve calculated your inventory at the start and end of your reporting period, here is the accepted COGS formula used by accountants:
(Beginning Inventory + Purchases) – Ending Inventory = COGS.
💡 Pro tip: Shopify makes it easy to find your cost of goods sold at the end of your calendar year—no manual calculations or formulas required. To get started, go to the Finances summary report from your Shopify Admin and select the time period you want the report to reflect.
Cost of goods sold example
Here’s a COGS example to demonstrate the calculation: Your company has the following information for recording the inventory for the calendar year ending on December 31, 2023. Your inventory at the beginning of the year is $20,000. At the end of the year, your inventory is $6,000. During the year, your company made $8,000 worth of purchases throughout the reporting period.
You can calculate COGS using the formula above: ($20,000 + $8,000) – $6,000, making your COGS $22,000.
Why calculating COGS is crucial for your business
Accurately determine gross profit and profitability
The COGS calculation helps you determine the gross profit you make on each sale, understand which products are most profitable, and help you set the best price. This helps you make smarter inventory decisions that reduce carrying costs, prevent obsolete inventory, and maximize space.
Optimize inventory and reduce carrying costs
With an efficient inventory management system, you can reduce storage costs and lower your days in inventory, reducing COGS. This can assist with purchasing, stocking, and production decisions—all of which are easier when you use the same platform for everywhere you sell: retail, ecommerce, and B2B included.
Shopify is the only solution on the market that delivers true and effective unified commerce for retailers by natively unifying ecommerce and POS channels on one centralized platform.
- A unified commerce platform provides a single source of truth for your entire business. Shopify provides the commerce platform powering millions of merchants in over 175 countries with 99.9% platform uptime, ensuring your data is accurate and accessible when you need it most.
Create a data-driven pricing strategy
Knowing your COGS per unit is the first step in setting your pricing strategy. It tells you the bare minimum you should charge to break even on a sale.
Getting pricing right has a massive effect on your bottom line. Even tiny price changes can lead to big profit gains. A 2024 NIQ report found that a 1% price increase can boost margins by around 11%, provided the same number of items are sold.
But costs are only half of the picture. You also have to consider what customers are actually willing to pay. This is where price elasticity comes in. It helps you figure out how much your sales might drop if you raise the price, or increase if you lower it.
So, while your COGS sets your price floor, price elasticity helps you find the ceiling. Your best, most profitable price is usually somewhere in between.
Manage your business tax liability
The IRS allows you to deduct the cost of goods used to make or purchase the goods you sell in your business.
By calculating all business expenses, including COGS, the company ensures they are offsetting them against total revenue come tax season. This means the business will only pay taxes on net income, thereby decreasing the total amount of taxes owed when it comes time to pay taxes.
Bear in mind that while high COGS means a lower income tax, that is not the ideal scenario, because it ultimately also means lower profitability for the company. It’s important to manage COGS efficiently to increase net profit margin.
Actionable strategies to reduce your COGS
Your COGS is a huge factor in how much profit your business makes. While these strategies focus on direct costs, a holistic approach to profitability should also aim to reduce overhead wherever possible. Lowering your COGS is a great place to start.
Optimize your inventory management
Excess or disorganized inventory ties up money that could be working for your business. The right data-driven tools help you free up that cash.
For example, with the Stocky app (which comes with Shopify POS Pro), you can use sales data and purchase suggestions to order the right amount of stock and avoid overpurchasing.
Within the Shopify Admin, you can also:
- Manage all your buying in one place. Use the built-in Purchase Orders tool to create and track orders, see your total costs, and manage supplier info.
- Put reordering on autopilot. Use Shopify Flow to get alerts when you're running low on stock. You can even set it up to automatically create a draft purchase order when an item’s count hits a certain number.
- Know exactly what you have. Connect a radio frequency identification (RFID) system, such as Simple RFID or Senitron, to your Shopify POS to achieve an inventory count accuracy of over 95%. When you know exactly what you have, you don't need to buy as much safety stock.
Retailers like Bared Footwear experienced inventory challenges firsthand with their previous operating stack. They relied on Lightspeed for POS transactions, but COO Alexandra McNab says: “Our online store was selling orders faster than the API could sync with Lightspeed, which also functioned as our inventory management system. Because of this, Lightspeed couldn’t present accurate inventory availability, which meant we risked overselling items if our stores wanted to continue transacting normally during an online sale.”
Since migrating to Shopify to unify inventory data across online and offline channels, Bared Footwear can now implement new fulfillment workflows to better serve customers.
“With Shopify, we have a unified commerce platform that makes the holistic experience we want to offer customers possible without burdening our team with clunky workarounds or high-risk situations,” Alexandra says.
Negotiate better terms with suppliers
Suppliers are partners, and there is usually room to create more value for both sides. Start by consolidating your supplier base. A classic study by McKinsey found that consolidating suppliers and standardizing terms can capture an estimated 2%–5% in purchase price savings, while also improving administrative efficiencies.
Supplier views show you how much you’re spending with each supplier, which is information you can use to ask for better prices on bulk orders. With Shopify Bill Pay, you can schedule payments to your suppliers right from your admin. This helps you manage your cash flow by deciding exactly when money goes out.
Leverage technology to automate production
Businesses that invest in smart manufacturing initiatives report up to a 20% improvement in production output and a 20% increase in workforce productivity. This reduces your unit COGS and can unlock around 15% in additional capacity.
Sync production with sales in real time. Integrate a manufacturing resource planning (MRP) app like Katana with Shopify to automatically sync sales orders, bills of materials (BOMs), and materials planning. A seamless connection helps trigger replenishment orders, route expectations, and keeps inventory data perfectly unified across every sales channel.
Analyze and reduce material waste
Every bit of scrapped material or inefficient process increases your COGS. Identifying exactly where waste occurs is the first step to reducing it. Apps like Katana can track how much material is wasted or scrapped during production for each item on your BOM.
💡 Pro tip: Use Shopify’s real-time inventory features like multi-location tracking and demand forecasting recommendations from Stocky to avoid ordering excess stock that risks becoming a write-off.
Understanding the limitations of the COGS formula
While the COGS formula helps calculate direct costs and assess profitability, it also comes with some limitations:
- Incomplete: The COGS formula only includes direct costs, such as materials and labor, but excludes indirect costs like marketing, administrative expenses, and overhead, which can impact overall profitability.
- Varying approaches: Different inventory valuation methods can lead to varying COGS results, affecting reported profits and tax liabilities. Choosing the wrong method can distort financial analysis.
- Fluctuating costs and inflation: Rising material and labor costs can impact the accuracy of COGS calculations, especially if a business does not frequently update its inventory valuation or cost tracking methods.
- Not real-time: COGS is typically calculated over a specific period, meaning it may not capture real-time fluctuations in production costs, potentially leading to outdated or misleading financial insights.
To overcome these limitations, retailers should regularly review their accounting methods, track both direct and indirect costs, and consult with financial professionals to ensure accurate financial reporting.
Use the COGS formula for your retail store
Whether you’re opening your first retail store or your fifth, the accounting process is tough. Business owners can’t control the price of each other’s suppliers. But what you can control is the accounting methods you use to track metrics like COGS.
Be thorough in your accounting practices. Partnering with a good accountant can improve your business, not just by taking the headache out of tax preparation and COGS formulas, but by providing financial advice that improves your bottom line.
Cost of goods sold (COGS) FAQ
Is COGS the same as purchase price?
No, COGS is not the same as the purchase price. The purchase price refers to the cost of acquiring a product or raw materials, while COGS includes all direct costs associated with producing and selling the product, such as labor, raw materials, and manufacturing expenses.
What is another name for the cost of goods sold?
COGS is sometimes referred to as the cost of sales or cost of revenue, depending on the business type and financial reporting terminology. However, cost of revenue and cost of sales both include additional line items that COGS does not.
What is the formula for COGS?
The cost of goods sold formula is: (Beginning inventory + purchases) — ending inventory. This formula helps businesses determine the total cost of goods sold during a specific period.
What is the difference between cost of sales and COGS?
Cost of sales is a broader term than COGS—it includes both product and service-related expenses. COGS specifically refers to the direct costs of producing physical goods, whereas cost of sales may include additional expenses like service delivery, consulting fees, and software licensing.
What is the rule of COGS?
The rule of COGS dictates that only direct costs related to the production or purchase of goods can be included in the calculation. This means expenses such as rent, marketing, and administrative costs should not be factored into COGS.
What should be included in the cost of goods sold?
COGS should include both direct and indirect costs, such as:
- Raw materials
- Packaging
- Shipping
- Direct labor (workers assembling or manufacturing the product)
- Depreciation of machinery and equipment used in production





