COGS calculator: cost of goods sold from your inventory and purchases
COGS = beginning inventory + purchases + freight-in and duty − purchase returns and discounts − ending inventory. Example: $12,000 + $30,000 + $1,500 + $800 − $600 − $15,000 = $28,700. On $60,000 of net sales that leaves $31,300 of gross profit, a 52.17% margin. If the result comes out negative or far too low, ending inventory holds stock that never went through purchases.
The calculator
Use the same period for every figure: a month, a quarter or a year. Inventory values are at cost, not at selling price.
The formula
Beginning inventory
+ Purchases, at the prices you paid
+ Freight-in, duty and other costs to bring stock in
− Purchase returns, allowances and discounts
= Goods available for sale
− Ending inventory
= Cost of goods sold
This is the order of Schedule C lines 35 to 42 for a US merchant, where purchases are taken net of returns and trade discounts and freight-in counts as part of the cost (IRS Publication 334). Step by step, with where each number comes from in Shopify: how to calculate COGS for a Shopify store.
A worked example
| Line | Amount |
|---|---|
| Beginning inventory | $12,000.00 |
| + Purchases | $30,000.00 |
| + Freight-in | $1,500.00 |
| + Duty | $800.00 |
| − Purchase returns and discounts | $600.00 |
| = Goods available for sale | $43,700.00 |
| − Ending inventory | $15,000.00 |
| = Cost of goods sold | $28,700.00 |
| Net sales | $60,000.00 |
| Gross profit | $31,300.00 (52.17%) |
Cost of goods purchased: the formula
Cost of goods purchased = purchases
− purchase returns, allowances and trade discounts
+ freight-in, duty and other costs to bring stock in
Cost of goods sold = beginning inventory + cost of goods purchased − ending inventoryIn the example above: $30,000.00 + $1,500.00 + $800.00 − $600.00 = $31,700.00 of goods purchased, and $12,000.00 + $31,700.00 − $15,000.00 = $28,700.00 cost of goods sold. The IRS takes purchases at the price after trade discounts, less returns and allowances, and counts freight-in as part of the cost (IRS Publication 334).
When the result is negative or too low
Cost of goods sold can't be below zero. If ending inventory is larger than goods available for sale, stock reached your shelves without passing through purchases. The usual causes:
- Deliveries never entered as purchases: stock received through a transfer or added by hand, with the supplier bill not yet booked.
- Ending inventory valued at a newer, higher cost than what was paid for the units on the shelf.
- A count that added units with no purchase behind them.
- Two periods mixed: purchases for one month and inventory values for another.
Fix the inputs before using the figure. A COGS that is too low makes gross profit look higher than it is.
Where the numbers come from in Shopify
| Number | Where |
|---|---|
| Beginning and ending inventory | Analytics > Reports > Month-end inventory value, set to the last day of each period. Since 1 October 2026 it counts On hand units (Shopify Help), valued at Cost per item. |
| Purchases, freight and duty | Your supplier bills and freight and customs invoices, not Shopify. |
| Net sales | Shopify's sales reports for the same period. |
Shopify's profit reports give a second COGS figure, from the cost recorded on each order. The two match only when Cost per item matches what you paid (why they differ).
How True COGS helps
- Every delivery is recorded with the price paid and its date, with freight and duty on paid plans.
- The month-end close on paid plans lists opening inventory, purchases, revaluations, closing inventory and cost of goods sold at what you paid.
- Inventory value shows Shopify's figure and the True COGS figure side by side, with the difference.
Related guides
Questions merchants ask
How do you calculate cost of goods sold?
Beginning inventory plus purchases plus freight-in and duty, minus purchase returns and discounts, minus ending inventory. $12,000 + $30,000 + $1,500 + $800 − $600 − $15,000 = $28,700.
Is COGS the same as Cost per item?
No. Cost per item is what one unit cost. Cost of goods sold is the cost of all the units you sold in a period.
What does a negative COGS mean?
Ending inventory is larger than everything you had available. Stock arrived without a purchase being recorded, or ending inventory is valued above what you paid. Fix the inputs before using the figure.
Are shipping costs part of COGS?
Inbound freight on stock you bought for sale is. Shipping orders to your customers is a selling cost, not cost of goods sold.
Where do I find beginning and ending inventory in Shopify?
In Analytics > Reports > Month-end inventory value, set to the last day of each period. Beginning inventory is the previous period's ending figure.
What is the cost of goods purchased formula?
Cost of goods purchased = purchases − purchase returns, allowances and trade discounts + freight-in and other costs to bring the stock in. Add it to beginning inventory and subtract ending inventory to get cost of goods sold.
Try True COGS free. True COGS is an inventory costing app for Shopify by Nexus Logic Systems. It records the price you paid on every delivery (a received purchase order or a transfer), with its share of freight and duty on paid plans, keeps every price with its date, and writes your moving weighted average cost, or FIFO cost on a paid plan, to Shopify's Cost per item. It is free for up to 25 variants with a cost on record; paid plans start at $29 a month or $290 a year.
Install from the App Store