Cost of Goods Sold (COGS) Calculator
COGS is the first cost line that cuts into the top line. This calculator follows the standard inventory rollforward: start with beginning inventory, add purchases or production cost, subtract ending inventory, and the remaining cost is assigned to goods sold during the period. If you also enter sales revenue, the tool shows gross profit and gross margin so the inventory movement connects directly to the income statement.
Use it for a monthly close, a quick retailer margin check, a restaurant food-cost review, a manufacturing class exercise, or a small-business forecast. The result is deliberately narrow: it does not measure every expense, it does not calculate net income, and it does not decide whether the business is healthy by itself. It answers one important question: how much inventory cost left the balance sheet and became an expense because goods were sold?
How the calculator matches the income statement
An income statement starts with revenue, often called the top line. COGS comes next for companies that sell products or inventory-based services. Subtracting COGS from revenue gives gross profit. That subtotal is still before payroll for sales teams, advertising, rent, software, management salaries, interest, and taxes.
The next step is operating analysis. If you subtract operating expenses from gross profit, you reach operating income, which is the same operating-profit line used by the EBIT calculator when interest and tax are excluded. Divide operating income by revenue and you have the metric in the operating margin calculator. Continue below operating income by subtracting interest and taxes and the path ends at the net income calculator. COGS therefore does not stand alone; it is the bridge between sales volume and the first profit subtotal.
Formula
The calculator uses the inventory flow shown in the form and rejects negative COGS:
When sales revenue is greater than zero, it also calculates:
The optional revenue input is not part of the COGS formula. It only allows the calculator to show how COGS affects gross profit and gross margin after the direct inventory cost is known.
Worked example matching the calculator
Suppose a shop enters beginning inventory of USD 10,000, purchases of USD 25,000, ending inventory of USD 8,000, and sales revenue of USD 40,000. The calculator first finds goods available for sale:
Then it subtracts ending inventory:
Because revenue was entered, the tool also computes gross profit:
Finally, it divides gross profit by revenue:
Those numbers match the default form values exactly: the primary result is USD 27,000 of COGS, with USD 35,000 of goods available for sale, USD 8,000 of ending inventory deducted, USD 13,000 of gross profit, and a 32.5% gross margin.
Benchmarks and interpretation
COGS benchmarks vary widely by industry. A grocery store can operate with a high COGS percentage and thin margins because inventory turns quickly. A software company may report little or no traditional COGS for licenses, although cloud hosting, support, and implementation costs may still appear as cost of revenue. A manufacturer usually has a more complex COGS line because direct labor and factory overhead are capitalized into inventory before being expensed.
The practical benchmark is your own history plus peers with similar economics. Track COGS as a percentage of revenue by month, product line, location, or customer segment. A rising COGS percentage may point to supplier price increases, freight changes, shrinkage, spoilage, discounting, warranty replacements, or an unfavorable sales mix. A falling percentage may indicate better purchasing, price increases, production efficiency, or a shift toward higher-margin products. Always compare like with like: annual COGS divided by annual revenue is meaningful, but monthly COGS divided by quarterly revenue is not.
Tips for accurate COGS
Use cost, not selling price, for inventory. A unit that sells for USD 50 might cost USD 31; only the USD 31 belongs in COGS. Match the period carefully: beginning inventory should equal the prior period’s ending inventory unless there was a correction. Include freight-in, duties, direct labor, or manufacturing overhead only when your accounting policy treats those costs as inventory. Keep abnormal waste, selling costs, and administrative overhead out of COGS unless your accountant has classified them there.
The formula also depends on a reliable ending inventory count. If ending inventory is too low, COGS is overstated and profit is understated. If ending inventory is too high, COGS is understated and profit looks better than it is. Cycle counts, SKU-level reconciliations, and consistent valuation methods such as FIFO, weighted average, or specific identification help prevent misleading results.
Sources
- Corporate Finance Institute, Cost of Goods Sold — overview of COGS and its relationship to gross profit.
- AccountingTools, Cost of Goods Sold — inventory-cost definition and formula discussion.
- IRS, Publication 538: Accounting Periods and Methods — accounting-period and inventory-method context for tax reporting.