How to Calculate Cost of Goods Sold (COGS) for Online Sellers
On this page
Cost of goods sold (COGS) is the direct cost of the products you sold in a period. It is the first number you subtract from revenue to find gross profit, and it matters for both pricing and tax. This guide explains how to calculate cost of goods sold for an online shop, what to include, and how to use it.
The COGS formula
For a period such as a year or a month:
COGS = beginning inventory + purchases − ending inventory
- Beginning inventory: the cost value of the stock you had at the start of the period.
- Purchases: the cost of stock or materials you bought or made during the period.
- Ending inventory: the cost value of the stock left at the end.
Example: a reseller's year
- Stock on 1 January: $4,000
- Stock bought during the year: $18,000
- Stock left on 31 December: $5,000
COGS = $4,000 + $18,000 − $5,000 = $17,000. If sales were $40,000, gross profit is $23,000 and gross margin is 57.5%.
What to include in COGS
Include costs that are directly tied to getting the product ready to sell:
- The purchase price of stock you resell.
- Raw materials and components for products you make.
- Packaging that is part of the product (jars, boxes, labels).
- Inbound shipping and import duties to get stock to you.
- Direct labour for manufacturing, if you pay people to make products.
What not to include
These are operating expenses, not COGS:
- Marketplace and payment fees (Etsy, eBay, Amazon, PayPal, Stripe).
- Shipping orders to customers (outbound postage).
- Advertising and marketing.
- Website, software and app subscriptions.
- Rent, utilities and general overheads (unless your tax rules treat some production costs differently).
They still reduce your profit, but they belong below gross profit. Tax rules on what counts as COGS vary by country, so confirm with an accountant before you file.
Per-unit COGS for pricing
For pricing, you need the cost of one unit:
Unit COGS = (materials + packaging + inbound costs) ÷ units
A soap maker buys ingredients for $120 and wrappers for $30 to make 100 bars, and pays $20 inbound shipping. Unit COGS = $170 ÷ 100 = $1.70 per bar. That figure goes into every pricing calculation, along with fees, shipping and your time.
Put your unit cost into the margin calculator to check your price:
Profit Margin Calculator
Open full calculatorFee breakdown
Enter your numbers to see the result.
Inventory valuation methods
When the cost of your stock changes over time, you need a method to decide which cost goes into COGS:
- FIFO (first in, first out): the oldest stock is treated as sold first. Common and allowed in most countries.
- Weighted average: each unit's cost is the average cost of all units available.
- Specific identification: used for unique items, such as one-off vintage pieces, where you know exactly what each item cost.
Resellers of one-off items often use specific identification: record what you paid for each item when you buy it.
Why COGS matters
- Pricing: without accurate unit COGS, you can't set a price that guarantees a margin.
- Product decisions: compare gross margin by product to see what's really profitable.
- Tax: in many countries COGS reduces your taxable profit, so accurate inventory records save money.
- Break-even: your variable cost per unit is a key input in break-even calculations.
Tips for tracking COGS
- Count stock at least once a year, ideally at your financial year end.
- Keep receipts for every purchase of stock and materials.
- Use a simple spreadsheet with item, date bought, cost and date sold.
- Record unit costs for new batches, since material prices change.
The bottom line
Calculate COGS with beginning inventory plus purchases minus ending inventory, use per-unit COGS to price every product, and keep good records. Then read how to calculate profit margin to turn COGS into pricing decisions.
This guide is general information, not accounting or tax advice.
Frequently asked questions
What is the formula for cost of goods sold?
COGS = beginning inventory + purchases during the period − ending inventory.
Are shipping costs part of COGS?
Inbound shipping to get stock to you is usually part of COGS. Postage to send orders to customers is usually an operating expense instead.
Are Etsy or Amazon fees part of COGS?
Marketplace and payment fees are generally treated as selling expenses rather than COGS, though they still reduce your profit.
What is the difference between COGS and gross profit?
COGS is the direct cost of the products sold. Gross profit is revenue minus COGS.