Guide · Cost of goods sold · Shopify brands
How to calculate COGS: the formula and the cost per unit
To calculate COGS for a period, add the purchases of the period to the inventory you started with and subtract the inventory left at the end. To calculate COGS per unit, add up what one item uses (materials with waste, packaging, labor and its share of overhead) and divide batch costs by the number of items you can sell.
Free for up to 10 products · 14-day trial on paid plans
Updated
- Beginning inventory
- $4,200.00
- + Purchases
- $3,150.00
- + Freight-in
- $230.00
- − Ending inventory
- $3,960.00
- Cost of goods sold
- $3,620.00
The cost of goods sold formula is COGS = beginning inventory + purchases − ending inventory, all valued at cost: a brand that starts October with $4,200 of stock, buys $3,380 of materials including freight and ends with $3,960 had a COGS of $3,620. COGS per unit is the cost of one item: materials (adjusted for waste) plus packaging and labor, divided by the batch yield, plus overhead per item. Shipping to customers, payment fees and marketing are usually operating expenses, not COGS.
What is the cost of goods sold formula?
Cost of goods sold for a period equals the inventory you had at the start, plus everything you bought for your products during the period, minus the inventory still on hand at the end. Whatever is no longer on the shelf was sold, used or lost, and that is what the period’s goods cost you.
COGS = beginning inventory + purchases − ending inventory
Three rules keep the result honest:
- Value inventory at cost, not at retail. Count what the materials, packaging and finished goods cost you, including what you paid to get them delivered.
- Purchases include freight-in, import duties and other costs of getting goods to you (the landed cost), minus supplier returns and discounts.
- Ending inventory of one period is the beginning inventory of the next, so a counting error in one month moves profit into the following month.
Worked example: COGS for one month
A small soap brand closes October. It counted $4,200.00 of oils, butters, fragrance, packaging and finished bars on October 1 and $3,960.00 on October 31, and its net sales for the month were $9,400.00.
| Line | Where the number comes from | Amount |
|---|---|---|
| Beginning inventory | Count on October 1, at cost | $4,200.00 |
| + Purchases | Supplier invoices for materials and packaging in October | $3,150.00 |
| + Freight-in | Delivery charged on those purchases | $230.00 |
| = Goods available for sale | $4,200.00 + $3,150.00 + $230.00 | $7,580.00 |
| − Ending inventory | Count on October 31, at cost | $3,960.00 |
| Cost of goods sold, October | $3,620.00 | |
gross profit = net sales − COGS = $9,400.00 − $3,620.00 = $5,780.00
gross margin = gross profit ÷ net sales = $5,780.00 ÷ $9,400.00 = 61.5%
In the US, sole proprietors report cost of goods sold in Part III of Schedule C, which follows the same structure for the year. This guide is general guidance, not tax advice: which costs your books put into inventory depends on your accounting method and local rules.
How do you calculate COGS per unit?
COGS per unit is the cost of making one sellable item: every material priced in the unit you buy it in and adjusted for waste, plus packaging and labor, divided by how many items the batch yields, plus that item’s share of overhead. It is the number you price from and the one Shopify keeps in Cost per item.
line cost = quantity in the price unit × price per unit ÷ (1 − waste)
labor = minutes × hourly rate ÷ 60
COGS per unit = (materials + packaging + labor) ÷ yield + overhead per unit
Worked example: COGS per bag of granola
One batch makes 12 bags. Almonds lose 5% to sorting and broken pieces, so the batch has to buy more than ends up in the bags.
| Line | In the batch | Price | Calculation | Batch cost |
|---|---|---|---|---|
| Rolled oats | 2.4 kg | $2.50 / kg | 2.400 kg × $2.50 | $6.00 |
| Honey | 0.9 kg | $11.00 / kg | 0.900 kg × $11.00 | $9.90 |
| Almonds, 5% waste | 1 kg | $14.00 / kg | 1.000 kg × $14.00 ÷ (1 − 0.05) | $14.74 |
| Coconut oil | 0.4 l | $9.00 / l | 0.400 l × $9.00 | $3.60 |
| Dried cranberries | 0.6 kg | $10.00 / kg | 0.600 kg × $10.00 | $6.00 |
| Kraft bags | 12 pcs | $0.42 / pcs | 12 × $0.42 | $5.04 |
| Labels | 12 pcs | $0.08 / pcs | 12 × $0.08 | $0.96 |
| Labor | 90 min | $18.00 / h | 90 min × $18.00 ÷ 60 | $27.00 |
| Batch total | $73.24 | |||
Divide the batch by its yield, then add overhead: $480 a month of kitchen rent and utilities spread over the 400 bags the brand plans to make each month.
| Part | Calculation | Per bag |
|---|---|---|
| Ingredients | $40.24 ÷ 12 | $3.35 |
| Packaging | $6.00 ÷ 12 | $0.50 |
| Labor | $27.00 ÷ 12 | $2.25 |
| Overhead | $480 a month ÷ 400 bags | $1.20 |
| COGS per bag | $7.30 | |
At $14.00 a bag, the gross margin is ($14.00 − $7.30) ÷ $14.00 = 47.9%. Counting only ingredients and packaging ($3.85 a bag) would show 72.5%, a margin the brand does not actually earn. And if a batch yields 11 sellable bags instead of 12, each bag costs $73.24 ÷ 11 + $1.20 = $7.86: yield is the items you can sell, not the items you planned.
Run the same arithmetic with your own materials in the free product cost calculator, or for food by weight in the recipe cost calculator. Labor rates and overhead rules are explained in labor and overhead in product costs. To keep the calculation for every product in one file, start from the free recipe costing spreadsheet template.
What is included in COGS, and what is not?
COGS includes the costs of getting a product made and ready to sell: materials, the packaging it is sold in, freight to bring materials in, and the labor and production overhead of making it. Costs of selling and running the business, such as shipping to customers, payment fees and marketing, are operating expenses below gross profit.
| Cost | In COGS? | Why |
|---|---|---|
| Raw materials and ingredients | Yes | They become the product. |
| Product packaging: jar, bottle, label, gift box | Yes | The product is sold in it. |
| Freight-in, import duties on purchases | Yes | Part of what the goods cost to get to you. |
| Normal waste and spoilage in production | Yes | Through the waste percentage or a lower yield. |
| Wages of people who make the product | Usually | Direct labor is a product cost; how your own time is treated depends on how you are paid. |
| Production overhead: workshop rent, equipment, utilities | Depends | Many makers include it per item for pricing; whether the books do depends on the accounting method. |
| Shipping to customers and mailer boxes | Usually no | Many brands book it as a fulfillment or selling expense; some report it in cost of sales. Pick one and keep it. |
| Payment processing fees | Usually no | A cost of selling, charged per order; some online brands report them in cost of sales. |
| Marketing, ads, samples given away | No | Operating expense. |
| Shopify plan, apps, office costs, accountant | No | Operating expense. |
Fees and shipping are not COGS, but every sale still pays for them, so a price has to cover them on top of COGS. How margin and markup relate to that price is explained in markup vs margin.
Period COGS or COGS per unit: which one do you need?
You need both: period COGS tells you what the month actually cost and belongs in your books, while COGS per unit tells you what each sale costs and is the number you set prices from. They answer different questions and are worked out from different data.
| Question | Period COGS | COGS per unit |
|---|---|---|
| Formula | Beginning inventory + purchases − ending inventory | (Materials + packaging + labor) ÷ yield + overhead |
| Data you need | Two inventory counts and the period’s invoices | A recipe or bill of materials with current prices |
| Used for | Profit and loss statement, taxes, gross margin of the month | Prices, margin per product, Shopify Cost per item |
| Catches | Waste, theft, counting gaps and price changes, all at once | Which product earns what, before a single sale |
| Misses | Which products the cost belongs to | Losses outside the recipe, such as a spoiled batch |
The two meet in a third way to get period COGS: add up units sold × the cost per unit recorded at each sale. If the granola brand sells 380 bags in a month at $7.30, the COGS of those sales is 380 × $7.30 = $2,774.00. Shopify’s profit reports work this way from Cost per item, and the gap between this figure and the inventory formula shows how much went to waste, write-offs or counting errors. For a closer look at that field, see how Cost per item works in Shopify.
Why does COGS come out wrong?
Most wrong COGS figures come from the inventory counts or from costs missing in the recipe, and almost all of them make profit look higher than it was. The usual causes:
- Ending inventory is overstated. Every dollar too high in the closing count is a dollar less of COGS: $500 too much stock in the October count would show a gross margin of 66.8% instead of 61.5%, and the next month absorbs the difference.
- Stock is valued at retail. Inventory at selling prices inflates the closing count in the same way.
- Freight-in is booked as shipping. Delivery on supplier orders mixed with postage to customers drops out of COGS.
- Unit costs are typed once and never updated. When a supplier raises a price, every product that uses the material costs more, and a cost per unit set last year no longer matches what the inventory formula says.
- Waste and yield are left out. Trimming, broken pieces, test batches and failed pours are part of what the sellable items cost.
How to track COGS in Shopify with Costory
Costory is a Shopify app that calculates COGS per unit from each product’s recipe and writes it to Shopify’s Cost per item for every variant, so the cost recorded with each sale is the real one. It runs inside the Shopify admin and is billed by Shopify.
COGS per unit from the recipe
Ingredients in g, kg, ml, l, pieces and other units, waste per line, batch yield, packaging, labor lines with hourly rates and overhead rules (a percentage, a fixed amount per item, or monthly expenses ÷ planned quantity). Recipes, labor and overhead are on every plan, including Free for up to 10 products.
Cost per item kept current
When an ingredient price changes, Costory recalculates every product that uses it and writes the new cost to Cost per item. Orders already placed keep the cost they sold at. More in Shopify COGS from recipes.
Profit by product and by order
Revenue after discounts, without shipping and taxes, minus the cost recorded at each sale, with refunded units left out. Set a payment fee percentage to see profit after fees as well. On Free the reports cover the last 30 days. See profit reports.
Inventory for the period formula
On Growth ($39 a month) and Pro, purchases split delivery and other costs across their lines, and the Stock valuation report shows what your ingredient stock was worth on any past date: the materials part of beginning and ending inventory. See inventory and purchasing.
Costory is not accounting software: it does not build a profit and loss statement or a tax inventory, and its Stock valuation counts ingredients, not finished goods you buy for resale, whose stock Shopify keeps. Hand its figures to your bookkeeper as inputs. Wondering whether a spreadsheet is still enough for your store? See Costory vs a costing spreadsheet.
Paid plans have a 14-day trial. Compare plans
Questions about calculating COGS
Is COGS the same as cost per unit?
No. COGS is a total for a period: what the goods you sold in that month or year cost you. Cost per unit is what one item costs to make or buy. They meet when you multiply: units sold × cost per unit recorded at each sale gives the COGS of those sales, which is how Shopify’s profit reports work out cost from Cost per item.
Does shipping to customers count as COGS?
Usually not. Freight you pay to get materials or stock to you is part of COGS, because it is part of what the goods cost. Postage and mailer boxes for sending orders to customers are often booked as a selling or fulfillment expense, though some businesses report them inside cost of sales. Either is a choice your accountant can confirm; what matters is to use the same one every month.
Are payment processing fees part of COGS?
Usually not. Card and payment provider fees are a cost of selling, not of the goods, so most books put them below gross profit as an operating expense, though some online brands report them in cost of sales. They still come out of every sale, so a price should cover them: a product with a 50% gross margin keeps 47% after a 3% fee (50% − 3%).
What if I do not count my inventory every month?
Then the beginning and ending inventory in the formula are estimates, and so is the month’s COGS. Either count at least the items that hold most of the value, or keep stock records that change with every purchase and sale, so ending inventory comes from the records instead of a count. A full count at year end then corrects whatever the records missed.
Should I include my own time in COGS?
For pricing, yes: put your production time in the cost per unit at the hourly rate you would pay someone else, or every price you set assumes your work is free. For tax, the rules differ; for example, a US sole proprietor does not list amounts paid to themselves as cost of labor on Schedule C. Ask your accountant how your books should treat it.
Do I value inventory at what I paid or at what I sell it for?
At what you paid: cost, including freight-in, not the retail price. Valuing stock at retail inflates ending inventory, which shrinks COGS and makes the month look more profitable than it was. When the same material was bought at different prices, use one method consistently, such as first in, first out or a weighted average.
Why does my COGS come out higher than my sales, or negative?
Almost always because of the inventory figures. A negative COGS means ending inventory was counted higher than beginning inventory plus purchases, often from valuing it at retail or counting stock that was already paid for in an earlier month twice. COGS above sales after a large purchase usually means the new stock was left out of the ending count.
Related
Product cost calculator
Cost per unit from materials, waste, packaging, labor and overhead, plus a price that keeps your margin after payment fees.
Open the calculator →Recipe costing template
A free .xlsx recipe cost spreadsheet: pack prices in g, oz, lb or ml, waste, labor, packaging and overhead, cost per item and a price from your margin.
Open the calculator →Shopify Cost per item
Where the Cost per item field is, how to fill it for every variant by hand, in the bulk editor or by CSV, and why it goes stale.
Read the guide →Calculate COGS per unit from your recipes.
Free for up to 10 products. Paid plans start with a 14-day trial.
Install free on Shopify