Cost of Goods Sold Calculator

Beginning inventory, purchases and ending inventory in — COGS, gross profit and margin out

Updated 2026-09-28

$
$
$
$
$
$
Goods available for sale
$70,500.00
Cost of goods sold
$49,200.00
Gross profit
$32,800.00
Gross margin
40.0%
Inventory turns in the period
2.50

COGS = beginning inventory + purchases + freight-in (+ direct labor) − ending inventory. A negative result means the ending count is higher than everything you had available — recheck the count or the purchase total.

Your numbers stay on this device. The page link keeps your inputs, so a bookmark or shared link reopens these results.

Cost of goods sold is the cost of the stock that actually left your business as sales in a period — not what you spent on stock. The two only match if your inventory level never changes. Getting COGS right is what makes your gross margin, your inventory turnover and the cost figure on your tax return true, and it takes three numbers you already have: what you started with, what you bought, and what you counted at the end.

The COGS formula

COGS = beginning inventory + purchases − ending inventory. Everything you had available to sell during the period, minus what is still on the shelf, is what you sold (or lost). Purchases should include what it cost to get the goods to you: inbound freight, import duties and customs fees. Manufacturers and makers also add direct labor and materials used in production.

Worked example for a quarter: beginning inventory $18,000, purchases $51,000, freight-in $1,500, ending inventory $21,300. Goods available = $70,500. COGS = $70,500 − $21,300 = $49,200. With net sales of $82,000, gross profit is $32,800 and gross margin is 40.0%. Inventory turned 2.5 times in the quarter ($49,200 ÷ the $19,650 average of opening and closing stock).

What goes into COGS — and what does not

The test is whether the cost attaches to the product before it is sold. Costs of running the shop and selling are operating expenses, not COGS.

Typical treatment for a small retailer or maker
Include in COGSKeep out of COGS (operating expenses)
Product purchase price, net of supplier discounts and returnsRent, utilities and store staff wages
Inbound freight, duties, customs brokerageShipping to customers and packaging for orders
Raw materials and components (makers)Marketing, ads and marketplace listing fees
Direct labor to make the product (makers)Card processing fees
Inventory written off as damaged or lost (shrinkage)Office supplies, software and bookkeeping

FIFO, LIFO and weighted average: same stock, different COGS

When purchase prices change, which units you count as sold changes the COGS figure. Say you bought 100 units at $10, then 150 at $11, then 100 at $12.50 — $3,900 for 350 units — and sold 220.

FIFO (first in, first out) counts the oldest units as sold: 100 × $10 + 120 × $11 = $2,320 COGS, leaving $1,580 of stock. LIFO (last in, first out) counts the newest first: 100 × $12.50 + 120 × $11 = $2,570 COGS, leaving $1,330. Weighted average cost uses $3,900 ÷ 350 = $11.14 a unit: 220 units = $2,451.43 COGS, leaving $1,448.57. In all three, COGS plus ending inventory equals the $3,900 you spent.

With rising prices, LIFO shows the highest COGS and lowest profit, FIFO the lowest COGS and highest profit. Most small businesses use FIFO or average cost because they match how stock physically moves. LIFO is not permitted under IFRS, and in the US a business that uses it for tax generally has to use it in its financial statements too — speak to your accountant before choosing it. Whatever method you pick, use it consistently.

Where the ending inventory number comes from

The formula is only as good as the closing count. A physical count at period end (or a perpetual system you trust, checked with regular cycle counts) gives the quantity; multiply by unit cost using your costing method. Count errors flow straight into COGS: overstate ending stock by $1,000 and COGS falls by $1,000, so profit — and the tax on it — is overstated by the same amount, then reverses next period.

COGS on your tax return

US sole proprietors and single-member LLCs report COGS in Part III of Schedule C, which follows the same layout as this calculator: inventory at the beginning of the year, purchases, cost of labor, materials and supplies, other costs, minus inventory at the end of the year. Your ending inventory for one year must be the beginning inventory for the next. This calculator is for planning and checking — confirm your figures with your accountant or tax software.

Keep the numbers in a spreadsheet

Ready-made Excel and Google Sheets templates that pick up where this calculator stops. One-off purchase, instant download.

  • Simple Profit & Loss (P&L) Statement Spreadsheet

    Log transactions; get a monthly and yearly P&L with margins.

  • Inventory Tracker & Stock Control Spreadsheet

    150 SKUs, stock in/out log, automatic on-hand counts, reorder alerts, a reorder list and a dashboard.

Frequently asked questions

How do you calculate cost of goods sold?

Beginning inventory plus purchases (including freight-in) minus ending inventory. For a maker, add direct labor and materials used in production.

Is COGS the same as what I spent on inventory?

Only if stock levels did not change. If you bought more than you sold, part of the spending is still sitting in ending inventory and is not yet COGS.

Does shipping count as cost of goods sold?

Freight to bring stock in usually does. Shipping orders out to customers is normally a selling expense, not COGS.

What is a good gross margin?

It varies widely by industry. Compare against your own history and your pricing plan first; the profit margin calculator shows the margin on any single product.

Can COGS be negative?

No. A negative result means ending inventory is higher than everything available — usually a miscount, a missing purchase invoice or stock valued at retail instead of cost.

Related reading

More free calculators

Stop calculating one number at a time

ExpressBizTools tracks cost, price, margin, stock levels, and tax on every product and invoice automatically — free, in your browser.

Start free

As an Amazon Associate, ExpressBizTools earns from qualifying purchases. Product links are affiliate links. Calculations are for general planning and are not tax, legal, or financial advice.