COGS Formula: Calculate Cost of Goods Sold

Title image with the text 'Calculate cost of goods sold'. A turquoise calculator with a card and a TAX label on a dark background.
Author: Harald Neuner // 15min // 27.11.2026
Glühbirnen Icon in türkis

The key points in 50 seconds

Summary

Cost of goods sold equals beginning inventory plus purchases minus ending inventory. It captures what the products you actually sold cost you, and it is the figure every margin, markup, and inventory metric is built on.

  • Inbound freight and duties belong in COGS. What you paid to get goods into your warehouse is part of their cost. Leaving it out inflates your margin on paper and understates your break-even point.
  • Outbound shipping and marketing do not. They are operating expenses. Mixing them into COGS makes your gross margin useless for comparison and for pricing.
  • The valuation method changes the number. FIFO, LIFO, and weighted average produce different results from identical stock movements whenever purchase prices move.
  • Accounting COGS is not your true cost of sales. Fulfillment fees, packaging, and returns processing sit outside the accounting definition but decide whether a product is profitable.
  • Benchmarks exist, but only per sector. Gross margin runs at 33.18 percent for general retail and 26.31 percent for grocery, so a COGS ratio only means something within your own category.

Cost of goods sold is the least glamorous number in a store’s financials and the one that quietly decides everything else. Gross margin, break-even, the price you can afford to discount to, and your inventory turnover ratio all rest on it. Get it wrong and every figure downstream is wrong in the same direction.

The formula takes one line. The difficulty lies in the boundaries: which costs belong inside, which belong in operating expenses, and how to handle the fulfillment and returns costs that an online store carries but a traditional accounting definition does not mention. This guide covers both the calculation and those boundaries.

What is cost of goods sold?

Cost of goods sold, usually abbreviated to COGS, is the direct cost of the products a business sold during a period. It measures what those specific goods cost to buy or produce, not what was purchased or held in stock during the same period.

That distinction is the whole point of the formula. Buying 10,000 units and selling 6,000 of them means only the cost of those 6,000 is an expense in that period. The rest stays on the balance sheet as inventory until it sells. COGS is therefore the bridge between your stock and your income statement.

What belongs in COGS

The tax definition is broader than most store owners assume. For a business that keeps inventory, cost of goods sold includes beginning inventory, purchases less items withdrawn for personal use, cost of labor, materials and supplies, and other costs such as containers, freight-in and overhead. For resellers, the IRS notes that labor is usually not part of cost of goods sold, because it mainly matters in manufacturing. Small businesses with average annual gross receipts of $31 million or less (threshold for 2025 returns) may also choose not to keep an inventory for tax purposes.1

For a retailer or online store, that translates into three practical items:

  • The purchase price of the goods, net of supplier discounts and rebates
  • Inbound freight, customs duties, and import handling, meaning everything paid to get goods into your warehouse
  • Direct handling of the goods before sale, such as assembling kits or relabeling. Whether handling labor belongs in COGS for tax purposes depends on your situation, so confirm it with your accountant.

Inbound freight is the item most frequently omitted, and on imported goods it can add a significant share to unit cost. Excluding it does not just distort the margin, it also feeds a wrong purchase price into every downstream calculation, including your economic order quantity, where holding cost is derived from that price.

What does not belong in COGS

Everything that is not tied to acquiring or producing the specific goods sold is an operating expense. That includes advertising and marketing, salaries outside production or direct handling, rent for offices, software subscriptions, payment processing fees, and shipping to the customer.

The last one causes the most arguments. Outbound shipping is a cost of fulfilling an order, not a cost of the goods, and standard practice keeps it out of COGS. That does not make it irrelevant, it makes it a separate line, and the section on e-commerce costs below explains why you still need to track it per product.

The COGS formula

The COGS formula subtracts closing inventory from the sum of opening inventory and purchases during the period. Everything that came in and did not remain in stock is treated as sold.

The standard formula

  • COGS = beginning inventory + purchases during the period − ending inventory

All three values are stated at cost, never at retail price. Beginning inventory is the closing figure from the previous period, purchases include inbound freight and duties, and ending inventory comes from a physical count or a reliable perpetual inventory system.

The formula contains an implicit assumption worth naming: anything that is gone and was not sold is treated as sold anyway. Theft, breakage, and unrecorded write-offs all disappear into COGS and inflate it. If your COGS moves without an obvious cause, shrinkage is the first place to look.

Goods available for sale

  • Goods available for sale = beginning inventory + purchases

This intermediate figure is the total value that could have been sold in the period, and it is worth calculating separately for one reason: it makes the split visible. Whatever share of goods available for sale ends up as closing inventory rather than as COGS is capital that did not convert in that period. Tracking that ratio over several periods is an early indicator of building overstock, well before it shows up in your inventory turnover ratio.

A worked example

An online store starts the year with inventory worth 180,000 dollars at cost. Over the year it purchases goods for 640,000 dollars including inbound freight and duties. The year-end count values remaining stock at 210,000 dollars. Revenue for the year is 1,000,000 dollars.

  • Goods available for sale: 180,000 + 640,000 = 820,000 dollars
  • COGS: 820,000 − 210,000 = 610,000 dollars
  • Gross profit: 1,000,000 − 610,000 = 390,000 dollars
  • Gross margin: 390,000 ÷ 1,000,000 = 39.0 percent
  • COGS percentage: 610,000 ÷ 1,000,000 = 61.0 percent

Gross margin and COGS percentage always add up to 100 percent, so reporting both is redundant. Pick one and use it consistently, because switching between them in different reports is a reliable source of confusion.

The e-commerce costs the formula leaves out

Accounting COGS answers a reporting question, not an operating one. An online store carries several costs per order that fall outside the definition and yet determine whether a product earns money, which is why the accounting figure alone is a poor basis for pricing decisions.

Fulfillment, packaging, and marketplace fees

Pick and pack fees, shipping materials, outbound shipping, and marketplace commissions all scale directly with units sold. They behave exactly like product costs even though they are classified as operating expenses. A product with a 45 percent gross margin and 22 percent of revenue going to fulfillment and commissions is a very different product from one with the same margin sold from your own warehouse.

The practical fix is a second figure alongside COGS. Take the accounting COGS, add packaging, fulfillment, marketplace fees, and returns processing, and you have a fully loaded cost of sales that tells you what the product actually costs to deliver. Continuing the example above, adding 18,000 dollars of packaging, 42,000 dollars of fulfillment fees, and 15,000 dollars of returns processing lifts the total to 685,000 dollars, so contribution before marketing falls from 39.0 to 31.5 percent.

Returns distort both sides of the equation

A returned unit that goes back into sellable stock reverses part of the COGS you already recorded, and it raises your closing inventory. A returned unit that cannot be resold does the opposite: the cost stays in COGS while the revenue reverses, so margin falls twice.

Two consequences follow. Calculate margin on net revenue after returns rather than on gross sales, and account for returns processing as a per-unit cost rather than as general overhead. Both are needed before a per-product margin figure is meaningful, and disciplined return management is what keeps the second number small.

Dropshipping and bundles

Two structures break the standard formula. In dropshipping there is no inventory to speak of, so beginning and ending inventory are near zero and COGS equals purchases. The formula still works, it simply collapses, and the meaningful figure becomes the per-order supplier cost.

Bundles and kits are the opposite problem. A bundle assembled from three individually stocked items needs its cost derived from the components, and the assembly labor belongs in COGS as direct handling. Where an ecommerce platform reports bundles at a flat estimated cost, margins on the components silently drift.

Inventory valuation changes the result

The COGS formula assumes you know what your ending inventory is worth, and that value depends on which units you assume were sold. Three methods are in use, and they produce different results from identical stock movements whenever purchase prices change.

FIFO, LIFO, and weighted average

  • FIFO, first in first out: the oldest units are treated as sold first. When purchase prices rise, COGS is lower and reported profit is higher.
  • LIFO, last in first out: the newest units are treated as sold first. When prices rise, COGS is higher and reported profit is lower. LIFO is permitted under US tax rules but not under IFRS.
  • Weighted average: all units carry the average cost of goods available for sale. It smooths price swings and is the simplest to operate at scale.

None of the three is more correct than the others, and the choice is a matter for your accountant rather than for your ops team. What matters operationally is consistency: switching methods between periods makes your margin trend meaningless, and comparing your COGS percentage against a competitor on a different method compares two different things.

Why this matters more in e-commerce

Imported goods bought in batches at different exchange rates and freight costs can vary by double digit percentages between purchase orders. Under weighted average that variation disappears into one blended cost, which is convenient for reporting and unhelpful for pricing, because it hides which batch is actually unprofitable.

Where purchase costs swing that widely, track cost per batch alongside the accounting valuation. It is the only way to see whether a price increase from a supplier has already eaten the margin on the stock you are currently selling, and it feeds directly into your price calculation.

COGS percentage and gross margin benchmarks

The COGS percentage expresses cost of goods sold as a share of revenue, and it is the figure that makes different sized businesses comparable. Its counterpart, gross margin, is simply the remainder.

  • COGS percentage = (COGS ÷ revenue) × 100
  • Gross margin = 100 − COGS percentage

What the sector data shows

Benchmarks only mean something within a category. Across US listed companies as of January 2026, gross margin runs at 33.18 percent for general retail, 35.30 percent for special lines retail, 34.22 percent for building supply retail, 30.57 percent for retail distributors, and 26.31 percent for grocery and food retail.2 The corresponding COGS percentages are roughly 67, 65, 66, 69, and 74 percent.

Two caveats apply before you compare yourself. The dataset contains no separate category for online retail, so any online store has to pick the closest product category rather than a channel benchmark. And these are listed companies with purchasing power a small store does not have, which makes them a demanding reference rather than a target.

Reading your own number

A COGS percentage is more useful as a trend than as a level. Rising over several periods with stable prices means either supplier costs have moved or your product mix has shifted toward lower margin items, and those two causes call for opposite responses. Falling sharply is worth checking too, because it is often a symptom of unrecorded inventory rather than of improved purchasing.

Calculate it per product category rather than only company wide. An aggregate figure averages a healthy category and a failing one into an unremarkable middle, and the aggregate is exactly where problems hide longest.

How to reduce cost of goods sold

Reducing COGS means lowering the cost of each unit sold or reducing the losses charged to it. Both paths are available to a small store, though they work on very different time horizons.

  1. Negotiate on volume you already have. Consolidating orders across products from the same supplier reaches discount thresholds without increasing total purchasing, and the discount applies to your full annual volume rather than to one order.
  2. Treat inbound freight as a lever, not a constant. Consolidating shipments, changing incoterms, or shifting a slow moving product from air to sea can move unit cost by several percent. It requires longer lead times, which then feed into your safety stock.
  3. Cut shrinkage and write-offs before cutting purchase prices. Losses charged to COGS are pure cost with no revenue against them. Tightening receiving checks and stock counts is usually faster than a supplier negotiation. Stock that never sells at full price belongs in a documented obsolete inventory process rather than in the warehouse.
  4. Shift the mix rather than the cost. Company wide COGS percentage falls when high margin products grow their share. Promoting the right products often beats renegotiating the wrong ones.
  5. Work the revenue side too. COGS percentage is a ratio, so it also improves when the same stock generates more revenue. Recovering visitors who already showed purchase intent is the cheapest form of that, and it is where uptain (uptain.de/en), a software for data-driven e-commerce marketing and shopping cart abandonment reduction, applies: exit intent popups and abandoned cart emails convert existing traffic rather than adding inventory.

Do you already know our plugin?

uptain prevents cart abandonment and increases the conversion rate and repeat purchase rate. No risk with performance-based commission.

➥ CALCULATE COMMISSION

Frequently asked questions about COGS

What is the formula to calculate COGS?

COGS equals beginning inventory plus purchases during the period minus ending inventory. All three values are stated at cost, not at retail price, and purchases include inbound freight and customs duties. The result is the cost of the goods actually sold in that period.

How do you find your COGS?

Take the closing inventory value from your previous period as the opening figure, add all purchases including inbound freight, and subtract the value of stock on hand at period end from a physical count or a reliable perpetual inventory system. The difference is your cost of goods sold.

What is the formula for gross profit and COGS?

Gross profit equals revenue minus cost of goods sold. Expressed as a percentage, gross margin equals gross profit divided by revenue. Gross margin and COGS percentage always add up to 100 percent, so calculating one gives you the other.

What are the two types of COGS?

Cost of goods sold splits into direct and indirect costs. Direct costs are the purchase price of the goods and direct labor. Indirect costs are items like inbound freight, containers, indirect labor, and overhead attributable to acquiring or producing the goods. Both belong in the calculation.

Conclusion

The COGS formula is three values and one subtraction, and the accuracy of the result depends almost entirely on the boundaries you draw. Inbound freight and duties belong inside, outbound shipping and marketing do not, and losses you cannot explain end up inside whether you intend them to or not.

For an online store, one addition makes the figure usable in practice: alongside the accounting COGS, maintain a fully loaded cost of sales that includes packaging, fulfillment, marketplace fees, and returns processing. The first number is what you report. The second is what tells you whether a product is worth selling.

Sources

1 Internal Revenue Service: Publication 334, Tax Guide for Small Business, for use in preparing 2025 returns, section on Cost of Goods Sold, https://www.irs.gov/publications/p334 (last accessed: 11/26/2026)

2 NYU Stern School of Business, Aswath Damodaran: Margins by Sector, US, data as of January 2026, https://pages.stern.nyu.edu/~adamodar/New_Home_Page/datafile/margin.html (last accessed: 11/26/2026)

  • How to Calculate Your Inventory Turnover Ratio

    The inventory turnover ratio shows how often you sell and replace your stock. This guide explains the standard COGS formula, why a sales-based calculation gives you a very different number, what benchmarks apply to online retail, and which levers actually move the ratio in an e-commerce operation.

    Zum Blogpost
  • Economic Order Quantity: Formula and Example

    The economic order quantity balances ordering costs against holding costs. This guide covers the EOQ formula and its variables, a worked example with realistic e-commerce figures, how to handle supplier minimum order quantities and volume discounts, and where the model stops working.

    Zum Blogpost
  • Obsolete Inventory: How to Spot It and Clear It

    Obsolete inventory is stock you can no longer sell at a normal price. It blocks capital, warehouse space and marketplace budget, and it distorts your balance sheet until you deal with it. This guide shows how to identify unsellable stock with aging reports, sell-through rate and days of supply, how write-downs and write-offs actually work, and which disposal route pays off when.

    Zum Blogpost