How to Calculate COGS for an Online Store (2026)
The COGS formula, what the IRS counts in cost of goods sold and what it does not, FIFO vs LIFO, the small-business inventory rules and a full worked example.
Your online store can show strong sales and still lose money if you do not know what the products you sold actually cost you. That number is cost of goods sold (COGS). It drives your gross margin, your pricing and your tax bill, and it is the line most new store owners get wrong.
This explainer shows how to calculate COGS, what the IRS includes and leaves out, how inventory methods like FIFO and LIFO change the result, and how marketplace and payment fees fit in. The tax rules below are for US federal returns for tax year 2025, from IRS Publication 334, Publication 538 and the Schedule C instructions.
This is general information, not tax or accounting advice. Rules depend on your situation, so confirm with a tax professional before you file.
What COGS is
Cost of goods sold is the cost of the products you actually sold during a period. It is not what you spent on stock during the period: some of that stock is still on your shelves, and some of what you sold was bought last year.
Your gross profit is your net sales minus COGS. Your gross margin is gross profit as a share of net sales. Everything else, such as ads, apps, platform fees and your own pay, comes out of gross profit.
The COGS formula
COGS = beginning inventory + purchases + other costs of acquiring goods − ending inventory
The IRS lays it out the same way in Part III of Schedule C (Form 1040), which sole proprietors and single-member LLCs use:
| Schedule C line | What goes there |
|---|---|
| 35 | Inventory at the beginning of the year (usually last year’s closing inventory) |
| 36 | Purchases, minus the cost of items you took for personal use |
| 37 | Cost of labor (usually only for manufacturers) |
| 38 | Materials and supplies (for manufacturers) |
| 39 | Other costs, such as freight-in |
| 40 | Add lines 35 through 39: the cost of goods available for sale |
| 41 | Inventory at the end of the year |
| 42 | Cost of goods sold: line 40 minus line 41 |
Corporations and partnerships report the same calculation on Form 1125-A, but the logic is identical.
What counts as COGS
Based on IRS Publication 334 (chapter 6) and Publication 538:
- What you pay for the products, at the price you actually pay. The IRS says you must use the price after trade discounts, not the list price.
- Freight-in: shipping, express and cartage on merchandise you buy for sale. The IRS says these are all part of cost of goods sold.
- Other charges you incur to acquire the goods. Publication 538 defines the cost of merchandise bought during the year as the invoice price, minus appropriate discounts, plus transportation or other charges incurred in acquiring the goods. Ask your accountant which of your costs fall here.
- For products you make: raw materials, direct and indirect production labor, and production overhead. Containers and packages that are an integral part of the product (a candle jar, a sealed bottle) are part of COGS.
Things you subtract from purchases:
- Purchase returns and allowances from your suppliers.
- Items you take for personal use, such as gifts to family. The IRS says you must exclude their cost from purchases.
- Cash discounts for paying early, if you choose to deduct them from purchases. The IRS lets you either reduce purchases by them or credit them to a separate account and report that as income, but you must be consistent.
What does not count as COGS
These are real costs, but they are costs of running and selling, not of the goods. You deduct them as business expenses instead:
- Store platform subscriptions and apps, such as your Shopify plan.
- Marketplace selling fees and payment processing fees. The IRS says the gross amount on a Form 1099-K is the total value of payments you received, and lists fees, refunds and shipping among the items you can deduct from that gross amount. The Schedule C instructions put commissions and fees that a regular seller pays to make sales on line 10.
- Shipping orders out to customers, and mailers or boxes that are not part of the product. The IRS says packages that are not an integral part of the product are shipping or selling expenses.
- Advertising, influencer fees and discounts you run as marketing.
- Your own pay as the owner, and staff who do not make the product (customer service, marketing). The IRS notes that small retailers usually have no labor costs that belong in COGS.
What about warehouse rent, storage and handling? Under the uniform capitalization rules (UNICAP), larger businesses must add some of these indirect costs to inventory. Small business taxpayers, defined below, are exempt from UNICAP, so most small stores deduct them as ordinary expenses.
Worked example: one year of COGS
Maple and Clay sells handmade ceramic mugs and kitchenware online, on its own store and on a marketplace. It is a sole proprietorship on a calendar year. Here is 2025:
| Item | Amount |
|---|---|
| Inventory on January 1, 2025 (last year’s closing count) | $18,000 |
| Purchases from makers and suppliers, after trade discounts | $64,000 |
| Minus items taken for personal gifts | −$400 |
| Freight-in on those purchases | $3,500 |
| Cost of goods available for sale | $85,100 |
| Minus inventory on December 31, 2025 | −$21,000 |
| Cost of goods sold | $64,100 |
Sales for the year were $190,000, and refunds and returns to customers were $6,000, so net sales were $184,000.
- Gross profit = $184,000 − $64,100 = $119,900
- Gross margin = $119,900 ÷ $184,000 × 100 = 65.2%
Not in COGS, and deducted elsewhere as expenses: $9,200 of marketplace and payment fees, $11,500 of outbound shipping and mailers, $14,000 of ads, and $1,100 of store subscription and apps.
A quick check the IRS itself suggests: divide gross profit by net receipts and compare the result with your usual markup. If you price products to earn about a 65% margin and your books show 45%, something is off in your sales, purchases or inventory figures.
Inventory methods: specific ID, FIFO and LIFO
When you buy the same product at different prices over the year, you need a rule for which cost goes to the items you sold and which stays in inventory. Publication 538 describes three:
- Specific identification: you match the actual cost to each item. This fits one-of-a-kind goods, such as vintage pieces or art.
- FIFO (first in, first out): you assume the oldest items sold first, so the items left in inventory carry your most recent costs.
- LIFO (last in, first out): you assume the newest items sold first. You must file Form 970 (or an equivalent statement) with the return for the first year you use it, and the IRS calls the LIFO rules “very complex.”
Worked example: FIFO vs LIFO
One mug design, one year:
| Units | Cost each | Total | |
|---|---|---|---|
| Beginning inventory | 100 | $6.00 | $600 |
| Bought in March | 300 | $6.50 | $1,950 |
| Bought in September | 200 | $7.00 | $1,400 |
| Available for sale | 600 | $3,950 |
The store sold 450 mugs, so 150 are left.
| FIFO | LIFO | |
|---|---|---|
| Which costs go to COGS | 100 at $6.00, 300 at $6.50, 50 at $7.00 | 200 at $7.00, 250 at $6.50 |
| COGS | $2,900 | $3,025 |
| Ending inventory | 150 at $7.00 = $1,050 | 100 at $6.00 + 50 at $6.50 = $925 |
Both columns add up to the same $3,950. The method only decides how it is split between this year’s COGS and next year’s opening inventory. As the IRS explains, when prices are rising LIFO gives a larger COGS and lower closing inventory, and FIFO the reverse; when prices fall, the opposite holds.
Whichever method you choose, the IRS says your inventory practices must be consistent from year to year, and you need IRS approval, usually through Form 3115, to change your method later.
Valuing inventory. On Schedule C, line 33, you choose how to value closing inventory: at cost, at the lower of cost or market, or by another IRS-approved method. Goods you cannot sell at normal prices because of damage or style changes can be valued at their real selling price minus the cost of disposing of them.
The small-business inventory exception
You may not have to keep a formal tax inventory at all. For tax years beginning in 2025, you are a small business taxpayer if:
- your average annual gross receipts for the 3 prior tax years were $31 million or less (the figure is indexed for inflation each year), and
- you are not a tax shelter.
A small business taxpayer can choose not to keep an inventory, but the IRS says it must still use a method for inventory that clearly reflects income. Two options are accepted:
- Treat inventory as non-incidental materials and supplies. You deduct the cost of the goods in the year you provide them to customers, not the year you buy them.
- Follow your financial accounting treatment. You treat inventory the same way your books do (or your applicable financial statement, if you have one).
If you choose to keep an inventory, you generally must use the accrual method for purchases and sales and value inventory each year to figure COGS in Part III of Schedule C. The IRS allows a combination method, so you can still use the cash method for your other income and expenses.
The practical point: even with the exception, stock you buy in December and sell in March generally is not a December expense. For your own decisions, keeping a real inventory and COGS in your books is worth it regardless, because without it you cannot see your margin.
How to calculate COGS step by step
- Count your inventory at the end of the period: every unit you own, wherever it is. The IRS says that includes goods you have title to that are still in transit, and goods out on consignment. Include stock held in a marketplace’s or 3PL’s warehouse.
- Value the count with your chosen method (specific ID, FIFO or LIFO) at cost.
- Pull the opening inventory from last period’s closing figure. If they differ, find out why; on Schedule C you must explain any difference.
- Total your purchases for the period from supplier invoices, after trade discounts and supplier returns.
- Add freight-in and other costs of acquiring the goods.
- Subtract personal-use items and any inventory you donated (the donation rules are in Publication 334).
- Apply the formula: opening inventory + purchases + freight-in − closing inventory.
- Check the margin against your markup, as above.
Do this monthly in your books. The tax return only needs it once a year, but your pricing and reordering decisions need it far more often.
Common mistakes
- Treating purchases as COGS. A big stock order makes one month look like a loss and the next like a windfall. Without opening and closing inventory, you cannot see your real margin.
- Putting fees in COGS. Marketplace, payment and platform fees are selling costs. Keep them in their own expense accounts so you can see what each sales channel really costs.
- Using the 1099-K as your sales figure without adjusting. The gross amount on a Form 1099-K is before fees and refunds. Report all your income, then deduct fees, refunds and other expenses from your records. Under the current IRS threshold, payment apps and marketplaces must send a 1099-K when your payments total over $20,000 in more than 200 transactions, but they may send one for less, and you must report all your sales either way.
- Forgetting freight-in. Inbound shipping and similar acquisition costs belong in the cost of your stock. Leaving them out overstates your margin.
- Counting sales tax as sales. Sales tax that is imposed on the buyer, which you collect and pass to the state, is generally not part of your gross receipts (the IRS treats a tax imposed on you as the seller differently, so check how your state’s tax works). If it runs through your sales account, your sales and margin look better than they are.
- Forgetting stock held by others. Units in a marketplace’s fulfillment center, at a 3PL, in transit or on consignment are still yours.
- Switching methods casually. Changing between FIFO and LIFO, or into or out of the small-business exception, is a change in accounting method that generally requires IRS approval.
- Skipping write-downs. Damaged or unsellable stock left at full cost inflates inventory and understates COGS.
Software that tracks COGS for you
Most accounting systems can track inventory quantities and cost and post COGS automatically when you record a sale, and many connect to store platforms and marketplaces so fees and refunds land in the right accounts. We compare the options for online sellers in our guide to the best accounting software for ecommerce.
If you are still choosing a platform, see our guide to the best website builder for ecommerce. Running a restaurant or food business instead? Our explainer on how to calculate food cost and prime cost applies the same inventory formula to a kitchen.
Frequently asked questions
What is the formula for COGS?
Cost of goods sold = beginning inventory + purchases (and other costs of getting goods ready to sell) − ending inventory. This is the same structure as Part III of Schedule C (Form 1040), lines 35 to 42.
Is shipping part of COGS?
Inbound shipping is. The IRS says freight-in on merchandise you buy for sale is part of cost of goods sold. Shipping orders out to customers is generally a shipping or selling expense, not part of the cost of the goods.
Are Shopify, Amazon or Etsy fees part of COGS?
No. Platform subscriptions, marketplace selling fees and payment processing fees are costs of selling, not costs of the goods. The IRS treats them as deductible business expenses. A Form 1099-K shows your gross payments, so deduct fees separately from your own records.
Do small online stores have to keep inventory for taxes?
Not always. For tax years beginning in 2025, a business with average annual gross receipts of $31 million or less over the prior 3 tax years (and that is not a tax shelter) can choose not to keep an inventory, as long as its method clearly reflects income. It can treat inventory as non-incidental materials and supplies, or follow the inventory treatment in its books. In most cases that still does not mean deducting stock the day you buy it.
Should I use FIFO or LIFO?
Most small stores use FIFO or, for unique items, specific identification. LIFO lowers taxable income when prices rise, but the IRS calls its rules very complex and you must file Form 970 to adopt it. Whichever method you pick, you must use it consistently and get IRS approval (Form 3115) to change it.
Sources and updates
Facts in this article were last checked against the official sources below on . Rules and thresholds change, so confirm anything you act on with the official source or a qualified professional. Spot something out of date? Tell us and we will re-check it. How we work: editorial policy.