Cost of goods sold
COGS formula calculator
COGS = beginning inventory + purchases − ending inventory. Put in your own numbers and the calculator shows the arithmetic. Under it, a FIFO example shows where the ending inventory number comes from, and what it costs you to pick weighted average instead. It all runs in your browser, with no email to give.
1. The COGS formula
COGS = beginning inventory + purchases − ending inventory
Cost of goods sold
2. Where ending inventory comes from: FIFO
One row per receipt, oldest first. The first row is what was on the shelf when the period started. Enter how many units you sold and FIFO takes them from the oldest rows.
| Layer | Units | Unit cost | Used by sales | COGS | Left | Left value | Remove |
|---|---|---|---|---|---|---|---|
| Total |
FIFO
Weighted average
Difference
The month-end that wouldn't tie out
In August 2026 the person who keeps one of our customers' books got on a call with me and one of our engineers. On screen were two numbers from our inventory valuation report: the end of January and the end of February. They trusted both numbers and wanted everything that happened between them, so the books could show how one became the other: every receipt, shipment and transfer, priced. Their purchase orders were received at one location and sent on to Amazon by transfer, and the landed costs turned up months after the goods.
I said the movements table had it all. "Everything that's inventory shows inventory movements." We scrolled right looking for a value column and there wasn't one, just quantities, so every row would have had to be priced by hand. Amazon wasn't in there either. "The Amazon ledger, because it's not just a third party, but it's a very nuanced third party, is a whole separate system," I said, and walked them to the FBA ledger screen instead.
Near the end of the call the bookkeeper asked whether COGS counted on the day an order shipped or the day it sold. Their Xero books went by sale date, month by month. I said by fulfillment, that our accounting module could be set up differently, and that it wasn't relevant to them anyway since they didn't use our accounting. Somebody asked whether to open a ticket. Our engineer said yes, and I left for another meeting. Looking back, the last part of my answer was wrong. Sale-date books against ship-date COGS was one of the gaps they were trying to explain, whoever's accounting they used.
The engineer rebuilt that February by hand afterwards, which took a couple of hours. Transfers had pulled on-hand value down more than sales had. That stock was on its way to Amazon at month-end, and the valuation report keeps stock in transit on its own line, outside on-hand, so two on-hand figures make it look like a sales month it wasn't. I wrote up a spec the next evening, and the result was the Inventory Value Change report, which walks from opening value to closing value one category at a time, FBA included.
The formula on the sample
COGS = beginning inventory + purchases − ending inventory. The sample is one product, March through June. 100 units on hand on March 1 at $8.00 is $800.00 of beginning inventory. A March purchase order of 300 at $8.50 and a May one of 200 at $9.40 are $4,430.00 of purchases. The 450 units that sold, at $19 each, all shipped in June, leaving 150. Valued at the May price, which is FIFO, those are $1,410.00, so COGS is $3,820.00 and gross profit on $8,550.00 of sales is $4,730.00, a 55.3% margin.
Purchases should include inbound freight, duty and brokerage; the landed cost calculator spreads those over a purchase order. Done with this formula by hand, a landed cost that arrives a month or two late lands in that later month's purchases unless you go back and restate the month the goods came in, which is a choice I've written about separately. Outbound shipping and FBA fees aren't in the formula. Some books carry them in cost of sales and some below gross profit, and switching mid-year makes the months hard to compare.
FIFO or weighted average
The formula ties out under either method as long as ending inventory and COGS are valued the same way. FIFO sends the oldest units out first: 100 at $8.00, 300 at $8.50 and 50 at $9.40 is $3,820.00, with the remaining 150 at $9.40. Weighted average prices all 600 units at $5,230.00 ÷ 600 = $8.7167, for COGS of $3,922.50 and ending inventory of $1,307.50. With prices rising, the average books $102.50 more cost in this period; under FIFO that amount sits in ending inventory until the May units sell. The sample's average is taken once over all 600 units. One recalculated at each receipt would match here only because nothing sold before June.
sku.io costs with FIFO. I picked it without weighing weighted average for long, mostly so a sale's cost could be clicked through to the purchase order it came from, and an accountant could make a decent case for the average. Neither method helps if the unit cost is wrong to begin with. In January 2022, the day after we landed our second customer, an importer who had just moved to a new 3PL told me COGS was being kept in a Google Sheet because the forecasting tool on trial did no costing, and the container price had gone from $6,000 to $20,000 while the unit costs in that sheet stayed at the supplier's price. I told them FIFO was how we costed and that our Xero integration was two or three months out.
When the formula is enough
One warehouse, one channel, a supplier whose price rarely changes and a count once a year: the formula and a spreadsheet will do. The spreadsheet stops being enough when you want COGS per SKU, and inFlow or Zoho Inventory will track cost per item at that size. Spreading one business-wide figure over products as a percentage of sales gives every product the same margin, the one it was handed. A product losing money on every order looks the same as the one paying the bills.
Questions people ask
What is the COGS formula?
Cost of goods sold = beginning inventory + purchases − ending inventory. Add freight and duty on the purchases to the purchases. In the example on this page: $800.00 + $4,430.00 − $1,410.00 = $3,820.00.
How do you calculate COGS with FIFO?
Take the units sold from the oldest cost layers first. In the example, 450 units sold come from 100 units at $8.00, 300 at $8.50 and 50 at $9.40, which is $3,820.00. The 150 units left are valued at $9.40, so ending inventory is $1,410.00, and the formula gives the same $3,820.00.
What is the difference between FIFO and weighted average COGS?
FIFO costs a sale at the oldest layers; weighted average costs every unit at the total cost divided by the total units. With the same three layers, weighted average is $8.7167 a unit and COGS is $3,922.50, which is $102.50 more than FIFO, because costs rose. When costs fall, the gap runs the other way. Both methods are accepted; the formula ties out with either.
Is shipping included in COGS?
Inbound freight and duty to get stock into your warehouse belong in the cost of the inventory, so they reach COGS when the units sell. Shipping an order out to a customer, marketplace fees and advertising do not go in the formula. Most businesses book those as operating expenses.
Why is my COGS negative?
Because ending inventory came out larger than beginning inventory plus purchases. Usually a purchase is missing from the period, or the ending count was valued at a different cost from the purchases.
Are my numbers uploaded anywhere?
No. The math runs in your browser. There is no form and no upload, and the calculator is excluded from the site’s session recording.
Does your month-end value refuse to tie out?
Bring two month-end inventory values that don't reconcile. I'll show you the movements between them in sku.io, receipt by receipt and shipment by shipment, including the ones Amazon holds.
Book a DemoFounder-led demo · 2-day onboarding · no onboarding fees