Cost of goods sold calculator
Calculate COGS for any period using the standard accounting formula — beginning inventory plus purchases minus ending inventory. Add revenue to also see gross profit and gross margin instantly. Free, no signup.
Try everything free for 14 days · no credit card
Calculate your cost of goods sold
Enter your inventory values for the period. Add revenue to also see gross profit and margin.
Stock on hand at the start of the period
Inventory bought during the period (incl. freight-in)
Stock on hand at the end of the period
Total sales for the period — adds gross profit & margin
Inventory available
$35,000
Beginning + Purchases
Ending inventory
$8,000
Deducted
COGS
$27,000
Cost of goods sold
Revenue
$50,000
For the period
Gross profit
$23,000
Revenue − COGS
Gross margin
46.0%
Profit / Revenue
How the COGS formula works
COGS = Beginning Inventory + Purchases − Ending Inventory. Take the dollar value of stock you had at the start of the period, add everything you bought during the period (including freight-in), then subtract what is left at the end. The difference is the cost of the inventory you actually sold.
Beginning inventory is the dollar value of all stock on hand on the first day of the period — pull it from your last balance sheet or accounting software. Purchases are all inventory bought during the period, including freight-in and direct production costs, net of returns and supplier discounts.
Ending inventory is the dollar value of stock left on the last day of the period, best obtained from a physical count or a perpetual inventory system. Enter revenue as well and the calculator extends the formula: Gross Profit = Revenue − COGS, and Gross Margin = Gross Profit ÷ Revenue — the numbers most tools leave you to work out by hand.
A worked example
A small retailer starts Q1 with $10,000 of inventory, buys $25,000 during the quarter, and ends with $8,000 on hand. COGS = $10,000 + $25,000 − $8,000 = $27,000 — those are the same numbers the calculator loads by default.
With $50,000 in revenue for the quarter, gross profit is $50,000 − $27,000 = $23,000, a gross margin of 46.0%. That $23,000 is what is left to cover operating expenses, taxes, and profit — which is why gross margin, not revenue, is the number to watch as you price and negotiate with suppliers.
What counts as COGS (and what doesn’t)
COGS is strictly the direct cost of the inventory you sold: raw materials and components, direct labor on the product (assembly, packing), freight-in and import duties, manufacturing supplies consumed in production, inventory storage attributable to stock, and inventory shrinkage or write-offs.
It does NOT include marketing and advertising, sales salaries and commissions, office rent and utilities, R&D, shipping to the customer, or general admin and software — those are operating expenses that live below the gross-profit line. On an income statement, COGS is subtracted from revenue to get gross profit; operating expenses are subtracted after that to get operating profit. For the valuation methods behind ending inventory, see the cost of goods sold guide and the FIFO vs LIFO comparison.
Frequently asked questions
Related tools
All tools →Automate reorder alerts with StockZip
Set a reorder point per SKU and StockZip alerts you the moment stock drops below it — no spreadsheets, no manual checks. Free for 14 days, no credit card.


