Cost of sales calculator
Cost of sales (also called cost of goods sold, or COGS) is the direct cost of the goods you sold in a period. This calculator works it out with the inventory method — cost of sales = beginning inventory + purchases − ending inventory — and, if you add revenue, also returns the cost of sales ratio, gross profit, and gross margin. Everything runs in your browser; nothing is uploaded.
How it works
Enter four numbers. Cost of sales comes from the three inventory figures; the ratio and profit figures need revenue as well.
| Output | Formula | Needs |
|---|---|---|
| Cost of sales | Beginning inventory + Purchases − Ending inventory | The 3 inventory fields |
| Cost of sales ratio | Cost of sales ÷ Revenue | + Revenue |
| Gross profit | Revenue − Cost of sales | + Revenue |
| Gross margin | Gross profit ÷ Revenue | + Revenue |
Steps
- Enter your revenue (net sales) for the period.
- Enter beginning inventory (opening stock at cost).
- Enter purchases made during the period.
- Enter ending inventory (closing stock at cost).
- Read the cost of sales, ratio, gross profit, and gross margin — they update as you type.
Example: revenue $10M, beginning inventory $2M, purchases $6M, ending inventory $1.5M → cost of sales = 2 + 6 − 1.5 = $6.5M, ratio 65%, gross profit $3.5M, gross margin 35%.
Cost of sales vs. operating expenses
Cost of sales covers only the direct cost of what you sold (purchases or production cost). Advertising, salaries, and rent are operating expenses and are not part of cost of sales. If you don't hold inventory, set beginning and ending inventory to 0 and cost of sales equals your purchases.
Nothing you type is sent anywhere — the whole calculation happens on your device.


