Finance tools
COGS calculator (cost of goods sold)
Calculate cost of goods sold (COGS) for a month, quarter, or year — free, with no sign-up. Use beginning inventory, purchases, and ending inventory for one accounting period (periodic inventory), or enter revenue and gross margin % when you only have a P&L. Results update as you type: COGS, optional gross profit and COGS % of revenue, plus CSV or PDF export.
What is cost of goods sold (COGS)?
Cost of goods sold (COGS) is the direct cost of inventory you sold during an accounting period. On the income statement it sits directly under revenue: Revenue − COGS = Gross profit. Gross profit shows whether pricing and purchasing are working before you pay operating expenses.
COGS covers materials and other direct costs tied to goods you sell — not rent, marketing, or admin salaries (those are usually operating expenses).
Under accrual accounting, COGS follows the matching principle: you record product cost in the same period as the related sales, using inventory balances instead of expensing every purchase when it hits your bank account.
COGS formula
Periodic inventory method
Goods available for sale = Beginning inventory + Purchases + Direct costs
COGS = Goods available for sale − Ending inventory
Equivalently: COGS = Beginning inventory + Purchases + Direct costs − Ending inventory.
When you know sales performance instead of inventory: COGS = Revenue × (1 − Gross margin % ÷ 100) — the same math as Revenue − Gross profit on an income statement.
Beginning inventory is the dollar value of stock at period start (from last period’s ending balance). Purchases are goods bought or produced during the period. Direct costs are optional freight-in, packaging, or other amounts you add to inventory cost. Ending inventory is what remains on hand at period end — a physical count or perpetual-system balance.
What is goods available for sale?
Goods available for sale is everything you could have sold in the period: inventory you started with, plus what you bought (and direct costs you capitalize into stock), before you subtract what is still on hand at period end.
That step clarifies a common mistake: purchases are not automatically COGS. You match the cost of what left inventory to the revenue you earned in the same period. The worked example below uses the same figures as the calculator’s default preset.
Periodic vs perpetual inventory (what this calculator uses)
Periodic inventory updates COGS at period end from balance-sheet snapshots: beginning inventory, purchases, and ending inventory. This calculator follows that approach — enter one period’s figures and the formula updates live.
Perpetual inventory records COGS on each sale (often via POS or inventory software). If you run perpetual books, you may still use From revenue & margin here to sanity-check gross profit, or enter rolled-up totals for a month or quarter in inventory mode.
FIFO, LIFO, and weighted-average costing change how ending inventory is valued, which flows into COGS. This calculator uses the dollar balances you enter; it does not pick a costing method for you.
Two ways to calculate COGS in this calculator
Choose the mode that matches the numbers in front of you — both recalculate instantly.
- From inventory — you have beginning and ending inventory plus purchases (month-end close, count day, quarterly books).
- From revenue & margin — you have sales and gross margin % from a P&L, not a full inventory roll-forward.
- Optional: add revenue in inventory mode to see COGS % and gross profit in the same view.
From inventory
Use beginning inventory, purchases, optional direct costs, and ending inventory for the same period.
Add optional revenue to see gross profit, gross margin %, and COGS % of revenue in the breakdown.
Best when you are closing books or validating a perpetual inventory report.
From revenue & margin
Enter revenue and gross margin % when you do not have inventory balances — typical when you are checking a P&L or lender summary.
Example: $100,000 in sales at 40% gross margin implies $60,000 COGS and $40,000 gross profit (same as revenue minus gross profit).
What's included in cost of goods sold?
COGS captures direct costs of inventory you sold in the period — not overhead to run the business. In the calculator, use Direct costs (optional) for freight-in, packaging, or other amounts you capitalize into inventory (not expensed immediately).
- Direct materials and merchandise you resell
- Direct labor tied to producing or fulfilling goods (when applicable)
- Freight-in and other costs capitalized into inventory
- Not COGS: rent, marketing, admin payroll, depreciation — those are usually operating expenses below gross profit
| Cost type | Usually COGS? | Typical treatment |
|---|---|---|
| Merchandise / raw materials | Yes | Inventory asset until sold; flows through COGS |
| Freight-in on stock | Often | Capitalize to inventory or direct costs line |
| Store rent / warehouse lease | No | Operating expense (SG&A) |
| Sales commissions | No | Operating expense |
| Shop-floor wages (production) | Often | Direct labor in COGS for manufacturers |
| Credit card processing on sales | Varies | Many SMBs book as operating expense — confirm with CPA |
COGS vs operating expenses: COGS moves with units sold; operating expenses support the business whether sales rise or fall. Both reduce profit, but only COGS sits above gross profit on the P&L.
COGS on the income statement
| Line | Example |
|---|---|
| Revenue | $100,000 |
| − Cost of goods sold | $60,000 |
| = Gross profit | $40,000 |
| − Operating expenses | (SG&A, etc.) |
| = Operating income | … |
On a typical P&L, revenue is the top line. Cost of goods sold is usually the first expense — subtract COGS to reach gross profit.
Reading COGS from a report: when you see revenue and gross margin % (or gross profit dollars) but not inventory detail, use COGS = Revenue − Gross profit — the same math as From revenue & margin above. When COGS is already a separate line, it should tie to your inventory roll-forward after close.
How to use this COGS calculator
Align the accounting period
Use beginning inventory at period start, purchases and direct costs during the period, and ending inventory at period end — monthly, quarterly, or annual.
Gather inventory balances
Pull beginning and ending inventory from the balance sheet and purchases for that same window.
Enter your numbers
Use From inventory for balance-sheet figures, or From revenue & margin if you only have sales and gross margin % from a P&L.
Read COGS and export
Review cost of goods sold, goods available for sale (in the breakdown), optional gross profit, and download CSV or PDF if needed.
Worked example (inventory method)
| Input | Amount |
|---|---|
| Beginning inventory | $10,000 |
| + Purchases | $25,000 |
| + Direct costs | $2,000 |
| = Goods available for sale | $37,000 |
| − Ending inventory | $10,000 |
| COGS | $27,000 |
Below is a quarterly cost of goods sold example using the calculator’s default preset — the same layout you might build in Excel.
With $90,000 revenue in the same quarter, gross profit is $63,000 (about 70% margin; COGS is roughly 30% of revenue). Add revenue in inventory mode to see those metrics beside COGS.
For P&L-only data: $100,000 revenue at 40% gross margin implies $60,000 COGS — switch to From revenue & margin instead of retyping inventory.
Common COGS examples by business type
COGS looks different by industry, but the periodic formula is the same: you move inventory balances and purchases into the period’s cost of goods sold.
| Business type | Typical COGS components | Example line items |
|---|---|---|
| Retail / ecommerce | Merchandise at purchase cost | Wholesale inventory, inbound freight, packaging tied to goods sold |
| Restaurant / food service | Food and beverage ingredients | Produce, proteins, beverages — not front-of-house wages (often operating expense) |
| Light manufacturing | Materials + direct production labor | Raw materials, shop-floor wages, factory utilities allocated to production |
| Reseller / distributor | Product cost from suppliers | Inventory purchases net of returns, import duties capitalized to stock |
Map your chart of accounts with your CPA — especially for cost of services vs inventory COGS when you do not hold physical stock.
COGS percentage (COGS % of revenue)
COGS percentage formula
COGS % = (Cost of goods sold ÷ Revenue) × 100
If gross margin is 40%, COGS is 60% of revenue. Enter optional revenue in inventory mode to see COGS % and gross margin in the results breakdown.
There is no single “good” COGS ratio — compare to your own trend and to businesses with a similar model. Planning ranges (not targets):
| Industry (illustrative) | COGS % of revenue | Notes |
|---|---|---|
| Grocery / mass retail | Often 60–75% | High volume, thin net margins |
| Restaurants | Often 28–35% food cost | Labor and rent sit below gross profit |
| Apparel retail | Often 50–65% | Markdowns affect ending inventory and COGS |
| Software / digital goods | Often low COGS % | Hosting and support may be OPEX, not COGS |
When to use this COGS calculator vs margin tools
Choose the right finance tool for the question you are answering. This page is built for period-level COGS on the income statement, not for setting price on a single SKU.
This COGS calculator
Period COGS from inventory roll-forward or from revenue + gross margin %.
Outputs: COGS dollars, goods available for sale, optional gross profit and COGS %.
Use at month-end close, lender requests, or inventory sanity checks.
Profit margin & markup calculators
Per-unit pricing from cost and selling price (or target margin).
Answers: margin %, markup %, price needed to hit a target margin.
Start with our profit margin calculator or markup calculator when costing one product line.
Next steps: estimate units needed to cover fixed costs with our break-even calculator. Track inventory efficiency with our days inventory outstanding (DIO) calculator (use COGS and average inventory for the same period), or receivables speed with our DSO calculator.
How to calculate COGS in Excel
| Cell | Label / formula |
|---|---|
| B1 | Beginning inventory |
| B2 | Purchases |
| B3 | Direct costs (optional) |
| B4 | Ending inventory |
| B5 | =B1+B2+B3 → Goods available for sale |
| B6 | =B5-B4 → COGS |
| B7 | Revenue (optional) |
| B8 | =B7-B6 → Gross profit |
| B9 | =B6/B7 → COGS % of revenue (format as %) |
Label column A and put amounts in column B. Format column B as Currency so totals stay readable:
From gross margin %: revenue in B7, margin in C7 (e.g. 40), then COGS =B7*(1-C7/100). Prefer a maintained template? Run the numbers here once and export CSV or PDF.
More free tools
Discover more calculators for time tracking, payroll, and HR.
Frequently asked questions about Finance tools
How do I calculate cost of goods sold?
COGS = Beginning inventory + Purchases + Direct costs − Ending inventory for the same accounting period. Enter those figures in the calculator above, or use revenue and gross margin % if you only have a P&L.
What is the COGS formula?
COGS (cost of goods sold) is the cost of inventory you sold in the period. On the balance sheet: beginning inventory + purchases + direct costs − ending inventory. On the income statement: COGS = revenue − gross profit.
How do I calculate COGS from gross margin?
COGS = Revenue × (1 − Gross margin % ÷ 100). Example: $100,000 in sales at 40% gross margin → $60,000 COGS. Select From revenue & margin in this calculator.
What is a good COGS percentage?
COGS % = (COGS ÷ Revenue) × 100. There is no universal target — compare your trend and peers. Restaurants often aim for roughly 28–35% food cost; grocery retailers may run 60%+ COGS with thin net margins.
What are common COGS examples?
Common COGS includes merchandise you resell (retail), food ingredients (restaurants), raw materials and direct factory labor (manufacturing), and freight-in capitalized to inventory. Rent, marketing, and most office payroll are usually not COGS.
How do I calculate COGS in Excel?
In Excel, list beginning inventory, purchases, direct costs, and ending inventory. Compute goods available for sale, then COGS = goods available − ending inventory. Add revenue for gross profit; divide COGS by revenue for COGS %. See the formula table on this page or export from the calculator.
Where do I find cost of goods sold on an income statement?
COGS is usually the first expense line below revenue. Subtract it from revenue to get gross profit. If the report shows revenue and gross margin % only, use COGS = revenue − gross profit (From revenue & margin mode here).
What is included in cost of goods sold?
Included: direct materials, direct production or fulfillment labor (when applicable), and freight-in on inventory. Usually excluded: rent, marketing, admin payroll, and depreciation — those are typically operating expenses below gross profit.
Is cost of goods sold tax deductible?
COGS generally reduces taxable income for many US businesses because it is subtracted from revenue before gross profit. Treatment depends on entity type and accounting method — this tool is for planning, not tax advice. See IRS Publication 334 and your CPA.
Can COGS be negative?
Yes, but it is usually a data problem. Negative COGS often means ending inventory is higher than goods available for sale suggests — recheck counts and that all inputs use the same accounting period. This calculator flags negative COGS with a warning.
How do I calculate COGS for a service business?
Many service businesses have little inventory COGS. Billable labor may appear as cost of services instead. This calculator is built for goods inventory; ask your CPA how to map your accounts.
Does FIFO or LIFO change this calculator?
FIFO, LIFO, and average cost change how ending inventory is valued, which affects COGS when you close the period. Enter the inventory balances from your books — this tool does not apply a costing method for you.
How is COGS different from operating expenses?
COGS varies with units sold and sits above gross profit. Operating expenses (SG&A) cover running the business — rent, sales, and admin — and are subtracted after gross profit.
How does COGS relate to inventory days (DIO)?
Days inventory outstanding (DIO) uses COGS and average inventory for the same period. After you calculate COGS here, use our DIO calculator for turnover and days-on-hand metrics.