Cost of Goods Sold Calculator
Calculate COGS from beginning inventory, purchases, eligible additional costs and ending inventory. Optionally calculate gross profit and gross margin from net sales.
COGS results
Cost of goods sold formula
COGS = beginning inventory + net purchases + eligible additional inventory costs − ending inventory. All four amounts are monetary values at cost. Beginning and ending inventory are balances; purchases and costs cover the interval between those dates.
Net purchases = gross purchases − purchase returns and allowances − purchase discounts. Goods available for sale = beginning inventory + net purchases + additional costs. This tool uses an aggregate periodic inventory bridge; it does not assign costs to individual inventory layers.
If net sales are entered: gross profit = net sales − COGS; gross margin = gross profit ÷ net sales × 100%; COGS as a percentage of sales = COGS ÷ net sales × 100%. When sales are zero, both percentages are undefined, not zero. Gross profit is not net profit because operating expenses, interest and taxes are not subtracted.
Verified examples
| Inputs | COGS bridge | Profit metrics |
|---|---|---|
| US$20,000 beginning inventory, 95,000 net purchases, 5,000 additional costs, 15,000 ending inventory; 150,000 sales | 20,000 + 95,000 + 5,000 − 15,000 = US$105,000 | US$45,000 gross profit; 30% margin; COGS 70% of sales |
| Gross purchases: 100,000; returns/allowances: 3,000; discounts: 2,000; other inputs as above | Net purchases: 95,000; COGS: US$105,000 | Same result; the net input is not added again |
| €8,000 beginning, 22,000 purchases, zero extra costs, 10,000 ending; 18,000 sales | COGS €20,000 | −€2,000 gross profit; −11.11% margin; COGS: 111.11% of sales |
| US$50,000 beginning; zero purchases/costs; 50,000 ending; zero sales | COGS US$0 | US$0 gross profit; percentages undefined |
Which costs should you enter?
Use amounts from the same entity, period, currency and inventory valuation basis. Eligible acquisition costs may include freight-in and other costs required to bring inventory to its present location and condition, subject to the applicable accounting policy. Enter them only if not already included in the purchase amount or inventory bridge.
Do not put ordinary advertising, selling expenses, freight-out or general administrative expenses into this merchandise inventory bridge. Do not use retail selling prices as inventory costs. Recoverable taxes, write-downs, production overhead, labor and special adjustments require the appropriate accounting treatment; the calculator does not decide that treatment.
Inventory methods and manufacturing limits
FIFO, LIFO where permitted, weighted-average and specific-identification policies can produce different inventory values. Those policies supply the input balances; this calculator does not simulate layers or determine which method is permitted. It is not a manufacturing schedule of cost of goods manufactured: raw materials, work in progress, finished goods and overhead must first be reconciled separately.
A decline in recorded inventory can include shrinkage or adjustments, not only sales. This simplified bridge does not separate those effects. If your records include unusual negative COGS adjustments, obtain an accounting reconciliation rather than forcing them into nonnegative inputs.
Input checks and limits
- Required active inputs must be nonnegative finite amounts; enter 0 explicitly rather than leaving a field blank.
- Each amount and total goods available must not exceed 1 trillion currency units. Inputs support up to six decimal places; no nonzero fraction smaller than 0.000001 is accepted.
- Returns plus discounts may not exceed gross purchases in breakdown mode. Ending inventory may not exceed goods available in this simplified model.
- Optional sales may be blank or zero. Positive sales allow margin calculations; losses and margins below zero are valid.
- Currency selection only formats results. Monetary sums use integer millionths to avoid binary floating-point subtraction errors; percentages are rounded to two decimals.
- A modern browser with BigInt support is required. This tool does not replace bookkeeping, tax reporting, an audit or professional accounting advice.
Educational arithmetic, not an accounting opinion or tax estimate. Check inventory classifications, adjustments and source records with a qualified accountant before using the result in formal reporting.
Frequently asked questions
Are purchases equal to COGS?
Not generally. Unsold inventory remains on the balance sheet. COGS reflects the inventory bridge after considering opening and closing balances and eligible costs.
Can gross profit be negative?
Yes. If COGS exceeds net sales, gross profit and margin are negative. That is a valid arithmetic result; the tool does not make a business-health verdict.
Why is ending inventory above goods available rejected?
It would imply negative COGS in this model. Check dates, currencies, missing purchases, duplication and adjustments. Such a case needs reconciliation outside the simplified bridge.
Related calculators
- Inventory Turnover Calculator — use COGS to calculate turns and days on hand.
- Cash Conversion Cycle Calculator — relate inventory, collections and supplier payment timing.
- Working Capital Calculator — calculate current assets minus current liabilities.