Cost of Goods Sold (COGS) Calculator
Find your cost of goods sold from beginning inventory, purchases, and ending inventory.
This calculator runs entirely in your browser. Nothing you enter is uploaded or stored.
How to use this tool
This COGS calculator works out your cost of goods sold for a period, which is the direct cost of the inventory you actually sold. Enter three numbers and press Calculate.
- Beginning inventory: the dollar value of the stock you held at the start of the period, taken from the closing inventory of the prior period.
- Purchases and production inputs: everything you added to inventory during the period, including raw materials, finished goods bought for resale, direct labor, and freight in.
- Ending inventory: the dollar value of the stock still on hand at the end of the period after a count or stock take.
If you also enter your net sales revenue, the tool calculates gross profit and gross margin so you can see how much of each sales dollar is left after the direct cost of inventory. You can copy or download the full breakdown.
The formula and how it works
Cost of goods sold tracks the value of inventory that left your business as sales. You start with what you had, add what you brought in, then subtract whatever is still sitting on the shelf.
COGS = beginning inventory + purchases - ending inventory
Gross profit = net sales revenue - COGS
Gross margin = gross profit / net sales revenue x 100
The logic is simple: anything you owned plus anything you added is the total inventory expense available to sell. Whatever you did not sell remains as ending inventory, so removing it leaves the gross production cost of the goods that customers actually bought. This figure flows directly into your income statement and sets your gross profit.
A real example
Picture a coffee roaster that began the quarter with 18,000 dollars of green beans and packaging on hand. During the quarter it bought another 42,000 dollars of beans, bags, and labels, which counts as purchases and production inputs. At quarter end a stock take valued the remaining inventory at 15,000 dollars. The cost of goods available for sale is 18,000 plus 42,000, which is 60,000 dollars. Subtracting the 15,000 dollars of ending inventory gives a COGS of 45,000 dollars. If net sales for the quarter were 90,000 dollars, gross profit is 90,000 minus 45,000, which is 45,000 dollars, for a gross margin of 50 percent.
Common questions
What is cost of goods sold?
COGS is the direct cost of the inventory a business sold during a period. It includes the materials, finished goods, and direct labor that went into what was sold, but not indirect costs like marketing or office rent. It is subtracted from revenue to find gross profit.
What counts as purchases and production inputs?
Anything added to inventory during the period: raw materials, components, finished goods bought for resale, direct labor used to make products, and freight in to receive the goods. These are the inputs that increase the pool of inventory you can sell.
Why do I subtract ending inventory?
Because goods still on the shelf at the end of the period were not sold, so their cost should not be counted as sold yet. Removing ending inventory from the cost of goods available leaves only the gross production cost of items that customers actually purchased.
What is the difference between COGS and operating expenses?
COGS covers the direct cost of producing or buying what you sold. Operating expenses cover the costs of running the business that are not tied to a specific unit, such as rent, salaries for non-production staff, advertising, and software. Only COGS is used to calculate gross profit.
How do I calculate gross margin from COGS?
First find gross profit by subtracting COGS from net sales revenue. Then divide gross profit by net sales revenue and multiply by 100 to get a percentage. A higher gross margin means more of each sales dollar is left to cover other expenses and profit.
This calculator provides educational estimates only and is not professional accounting or tax advice. Inventory valuation methods such as FIFO, LIFO, and weighted average can change your numbers. Consult a qualified accountant for your specific situation.