COGS Calculator
Work out cost of goods sold for a period from beginning inventory, purchases, freight in and ending inventory, set up for online stores.
Your numbers
Your result · updates as you type
Cost of goods sold
$93,400
Beginning inventory plus purchases (with freight in, minus returns) leaves $125,400 of goods available. Subtracting ending inventory of $32,000 gives $93,400 of cost of goods sold.
- Goods available for sale
- $125,400
On Shopify, set Cost per item on each product so your reports match this figure. In WooCommerce, turn on the core cost feature at WooCommerce → Settings → Advanced → Features → Cost of Goods Sold, which adds a cost field to each product's General tab.
Breakdown
- Beginning inventory
- $28,000
- Purchases
- $95,000
- Freight and duty in
- $4,200
- Purchase returns and allowances
- −$1,800
- Goods available for sale
- $125,400
- Ending inventory
- −$32,000
- Cost of goods sold
- $93,400
The COGS formula
Example: the default numbers
- Beginning inventory + purchases + freight in
- $28,000 + $95,000 + $4,200 = $127,200
- Less purchase returns and allowances
- − $1,800 = $125,400 goods available
- Less ending inventory
- − $32,000
Cost of goods sold = $93,400 for the period.
Freight and duty to bring inventory in belong here, in cost of goods, not in your operating expenses. Leaving them out understates COGS and overstates gross margin.
Tracking cost per item in your store
- 01
Shopify
Set Cost per item on each product's pricing details, so Shopify's reports track cost and profit alongside sales.
- 02
WooCommerce
Turn on the core cost feature at WooCommerce → Settings → Advanced → Features → Cost of Goods Sold, which adds a cost field to each product's General tab.
- 03
Matching this calculator
This calculator works at the period level (beginning/ending inventory and purchases), which matches how your accountant or P&L reports COGS, rather than per unit.
Questions people ask
What is cost of goods sold?
The direct cost of the inventory you actually sold in a period: what you started with, plus what you bought (including inbound freight and duty), minus what you ended with.
Should shipping to my customers be included in COGS?
No, only freight and duty to bring inventory in. Outbound shipping to customers is usually a separate cost, not part of COGS.
Why does ending inventory reduce COGS?
Because it wasn't sold. Goods available for sale includes everything you had access to; subtracting what's left over isolates what actually left as sales.
How is this different from gross margin?
COGS is a cost figure. Gross margin is revenue minus COGS, as a dollar amount or a percentage of revenue. Enter your revenue here to see both.
Related tools
Last reviewed 30 September 2026.
