Answer

How do I calculate cost of goods sold for an online store?

The cost of goods sold formula is the inventory you started with, plus the inventory you bought, minus the inventory you still have at the end. For an online store, "bought" means the full cost of getting stock ready to sell, freight in included, and "still have" means every unit you own, including stock sitting in an Amazon fulfillment center.

By [[FILL: author name]] · Reviewed by [[FILL: reviewer name]] · Reviewed [[FILL: date]] · 5 min read

On this page

What is COGS, and how do you calculate it?

answers / cost-of-goods-sold-online-storeSAMPLE · DEMO STORE

Cost of goods sold — September

DEMO OUTDOOR CO. · ALL CHANNELS · USD

Cost of goods sold — September (sample from a demo store)
Beginning inventory52,300.00
Purchases, incl. inbound freight & duty24,890.40
Goods available for sale77,190.40
Ending inventory(54,000.00)
Cost of goods sold23,190.40
= 36.0% of net sales 64,490.00

SAMPLE · DEMO STORE · NOT A CLIENT

Cost of goods sold (COGS) is what the products you sold in a period cost you to buy and get ready to sell. It is matched against the sales of those same products, so it changes with what went out the door, not with what you paid suppliers that month. The IRS puts it simply: if you make or buy goods to sell, you deduct the cost of goods sold from your gross receipts on Schedule C.[1] For an online store, that means the landed cost of every unit shipped to a customer, from every channel and every warehouse.

The cost of goods sold equation is: beginning inventory + purchases − ending inventory = COGS. Start with what was on the shelf when the month opened. Add everything you bought to sell. That total is what you could have sold. Take away what is still on hand at month end, and what is left is the cost of what actually went out the door.

The IRS sets out the same steps for the year on Schedule C, lines 35 to 42: beginning inventory, purchases, labor, materials and supplies, other costs, then ending inventory subtracted.[1] On Schedule C, freight-in is listed under line 39, other costs; either way it is part of cost of goods sold.[1] Treasury regulations add to the invoice price "transportation or other necessary charges incurred in acquiring possession of the goods"; we treat import duty, which has to be paid before you can take the goods, as one of those charges.[2] We run the formula every month, so margin is known month by month and not only at year end.

What counts in COGS for an online seller

Costs of getting a product ready to sell go into COGS. Costs of selling it, once it is ready, sit below gross profit as operating expenses.

What counts in cost of goods sold for an online seller
CostWhere it goes
Product cost from your supplierCOGS
Inbound freight to your warehouse, a 3PL or a fulfillment centerCOGS[1]
Import dutyCOGS, as a charge of acquiring the goods[2]
Packaging that is part of the productCOGS[1]
Shipping boxes and mailers that are not part of the productShipping or selling expense[1]
Shipping to the customerSelling expense
Marketplace referral and fulfillment fees, payment processingSelling expense
Advertising, software and subscriptionsOperating expense[1]

Where marketplace fulfillment fees belong is a judgment call that sellers make differently. Our books keep them below gross profit, with the other marketplace fees, so gross margin shows product economics and the fee line shows channel economics. Whichever you choose, use it every month. One more rule from the IRS: stock you take for personal or family use comes out of purchases, not into COGS.[1]

Why it goes wrong for sellers

The formula is simple. Seller books break it in four predictable places.

  1. 01

    Purchases booked straight to COGS

    A supplier payment goes to cost of goods sold the day it's paid, so any month you restock looks worse than it was and any month you sell down looks better.

  2. 02

    Stock at Amazon never counted

    Units in fulfillment centers are still yours. Leave them out of ending inventory and cost of goods sold is overstated by exactly their cost.

  3. 03

    Freight and duty left out of product cost

    When inbound freight sits in a general shipping expense, cost of goods sold looks lower and gross margin looks higher than it is.

  4. 04

    Returns that never go back into stock

    A returned unit that is put back on sale is inventory again. Book the refund but not the unit, and cost of goods sold stays too high.

What it costs to get wrong

Every one of those errors moves gross margin by the change in inventory. In our demo store, stock grew by 1,700.00 in September. Book purchases as COGS and that 1,700.00 disappears from profit.

Demo store gross margin, inventory counted vs purchases booked as COGS
LineCounted properlyPurchases booked as COGS
Cost of goods sold23,190.4024,890.40
Gross profit31,425.4529,725.45
Gross margin48.7%46.1%
Difference1,700.00 · 2.6 pts

SAMPLE · DEMO STORE · NOT A CLIENT · gross profit after marketplace fees of 9,874.15

One month, a 2.6-point swing. The error flips direction every time you restock or sell down, so the margin you price and reorder on is not the margin you earn. It also reaches your tax preparer: the year-end inventory figure feeds Schedule C line 41.[1]

Gross margin vs net margin

Gross margin is net sales minus cost of goods sold, as a share of net sales; the IRS calls the dollar figure gross profit.[1] Net margin is what is left after every other cost as well: marketplace fees, advertising, software, wages, rent, interest and tax. Gross margin tells you whether the product makes money; net margin tells you whether the business does.

Demo store September, gross margin before and after marketplace fees
LineUSD% of net sales
Net sales64,490.00100.0%
Cost of goods sold(23,190.40)36.0%
Gross profit41,299.6064.0%
Marketplace fees(9,874.15)15.3%
Gross profit after marketplace fees31,425.4548.7%

SAMPLE · DEMO STORE · NOT A CLIENT

Net margin comes from taking the store's remaining operating costs off that 31,425.45. To see the same split on a single product, try the marketplace profit calculator.

When to get help

If your margin swings month to month without a reason you can name, or you have never counted the stock at Amazon, the formula is fine and the inputs are the problem. That is the work our monthly e-commerce bookkeeping does every month: purchases into inventory, every location counted, landed cost on every unit, and cost of goods sold that ties to the stock you hold.

Publication 334 also lets a business that qualifies as a small business taxpayer (average annual gross receipts over the 3 prior tax years of $31 million or less for tax years beginning in 2025, or $32 million for 2026, and not a tax shelter)[3] choose not to keep an inventory, using a method that still clearly reflects income.[1] Which method suits your return is a question for your tax preparer. Either way, books that track inventory give them the numbers to decide with.

PHOTO
[[FILL]]
Reviewed

Reviewed [[FILL: date]] by [[FILL: reviewer name]], [[FILL: credential, exactly as held]]

Written by [[FILL: author name]], e-commerce bookkeeper

Last updated [[FILL: date]] · Re-checked: yearly, or when a source changes

Sources

Sources

  1. Publication 334 (2025), Tax Guide for Small Business — How To Figure Cost of Goods Sold; Inventories · Internal Revenue Service fetched 7 Oct 2026
  2. 26 CFR 1.471-3(b), Inventories at cost (eCFR) fetched 7 Oct 2026
  3. Rev. Proc. 2025-32 (2026 inflation adjustments), §448(c) gross receipts test fetched 7 Oct 2026
  4. Publication 538 (01/2022), Accounting Periods and Methods — Inventories · Internal Revenue Service fetched 7 Oct 2026

General information about bookkeeping, not tax or legal advice for your situation.

How this answer was written, sourced and reviewed: editorial policy.

See where your books stand — free.

Get a written review of every channel: what's reconciled, what's missing, and the exact price to fix it. No card, no commitment.

Get my free books review