Finance calculator

Free cost of goods sold calculator

Find your cost of goods sold in two seconds. Enter your beginning inventory, your purchases, and your ending inventory — add revenue to also get gross profit and your gross margin. The calculator returns COGS (beginning + purchases − ending), gross profit, and the COGS ratio — updated live, as you type.

InputsLive
Inventory for the period
Beginning inventory
$
Purchases this period
$
Ending inventory
$
Revenue (optional)
$
Result
Cost of goods sold
$85,000
The direct cost of the goods you sold this period.
COGS$85,000
Gross profit$65,000
COGS ratio56.7%

Estimates only, based on the values you enter. Not accounting or tax advice.

Results are estimates. Consult a professional.

Definition

What is cost of goods sold (COGS)?

Cost of goods sold (COGS) is the direct cost of producing the goods a business actually sold during a period — the raw materials, the direct labour, and the factory overhead that went into the units that left the shelf. It is the first cost subtracted from revenue on the income statement, and what's left is gross profit. This cost of goods sold calculator returns COGS the moment you enter your beginning inventory, your purchases, and your ending inventory — and adds gross profit and the COGS ratio when you supply revenue.

COGS = beginning inventory + purchases ending inventory
gross profit = revenue COGS
COGS ratio = COGS ÷ revenue

The logic is inventory accounting in one line: take what you started with, add what you bought or made, and subtract what is still sitting in the warehouse at the end. Whatever is missing must have been sold — and its cost is your COGS. Because it counts only the cost of goods that actually sold, COGS rises and falls with sales volume, which is what makes it a direct cost rather than an overhead.

Method

How to calculate cost of goods sold

Calculating COGS is a three-step process that works off two inventory snapshots — one at the start of the period, one at the end — and everything you added in between.

  1. Find your beginning inventory. The dollar value of stock on hand at the start of the period. This is simply last period's ending inventory carried forward.
  2. Add your purchases. Everything you bought or manufactured during the period — inventory purchases plus the direct materials, direct labour, and factory overhead that go into finished goods.
  3. Subtract your ending inventory. The dollar value of stock still unsold at the end of the period, counted in a physical or perpetual inventory. Beginning + purchases − ending = COGS.
COGS is reported for a period (a month, quarter, or year), not a point in time. The two inventory figures are snapshots at the period's boundaries; purchases is the flow in between.
What counts

What is included in COGS

COGS captures only the direct costs of producing what you sold — costs that would not exist if you made nothing. Three categories make up almost every COGS figure.

  • Raw materials. The cost of the materials and components that physically go into the product — the leather in a shoe, the flour in a loaf, the goods a retailer buys to resell.
  • Direct labour. The wages of the people who build, assemble, or prepare the product — the factory line, the bakers, the assembly team.
  • Manufacturing overhead. The indirect production costs tied to making the goods — factory utilities, equipment depreciation, and maintenance on the production line.
The value of unsold stock on hand at the start of the period — last period's ending inventory carried over.
Inventory bought or produced during the period, including the direct materials, direct labour, and factory overhead added to finished goods.
The value of stock still unsold at the close of the period, measured by a physical count or a perpetual inventory system.
A cost that can be traced straight to a product and rises with output — materials, direct labour, factory overhead. The defining feature of what belongs in COGS.
Comparison

COGS vs operating expenses: what stays out

The single most common COGS mistake is folding in costs that belong elsewhere. The dividing line is simple: COGS holds the costs of making and selling the product; operating expenses (often shown as SG&A) hold the costs of running the company. Put another way, if a cost would still be there even if you produced nothing this month, it is an operating expense, not COGS.

CostIn COGS?Why
Raw materials & componentsYesDirect material cost of the product
Factory / production labourYesDirect labour that makes the goods
Factory utilities & depreciationYesManufacturing overhead tied to output
Office rent & admin salariesNoOverhead — runs the company, not the product
Marketing & advertisingNoA selling expense (SG&A), not a production cost
Interest & income taxesNoNon-operating — sit far below gross profit

Direct production costs go in COGS; everything that keeps the business running is an operating expense.

COGS is an expense, but inventory itself is an asset. A purchase sits on the balance sheet as inventory and only becomes COGS on the income statement at the moment the item is sold — which is why COGS tracks sales, not spending.
Worked example

A worked example using the cost of goods sold calculator

Example: a small apparel brand

Thread & Co. is closing its books for the year. It started January with $20,000 of inventory, bought and produced $80,000 of stock over the year, and counted $15,000 of unsold inventory on December 31. It booked $150,000 in revenue. Here is how the calculator works through it.

Step 1 — Add beginning inventory and purchases

Start with what was on hand plus what came in during the year: $20,000 of beginning inventory + $80,000 of purchases = $100,000 of goods available for sale.

Step 2 — Subtract ending inventory

Take out what is still unsold at year-end: $100,000 of goods available − $15,000 of ending inventory = $85,000. That $85,000 is the cost of goods sold.

LineAmount
Beginning inventory$20,000
Add purchases+$80,000
Goods available for sale$100,000
Less ending inventory−$15,000
Cost of goods sold$85,000

COGS = $20,000 + $80,000 − $15,000 = $85,000.

Step 3 — Subtract COGS from revenue for gross profit

$85,000 COGS · $65,000 gross profit · 56.7% COGS ratio
Revenue of $150,000 minus $85,000 of COGS leaves $65,000 of gross profit — a 43.3% gross margin. The COGS ratio (COGS ÷ revenue) is 56.7%, meaning 57 cents of every sales dollar went to producing the goods. The calculator shows all three the instant you add revenue.

Now see how that compares. A 43% gross margin is healthy for apparel, where 50–60% gross margins are typical for established brands but thinner for new ones still paying full price for small production runs. The next sections show how the inventory method you choose can move this COGS figure, and how COGS drives the gross margin that the whole business is judged on.

SERP gap

How FIFO, LIFO, and weighted average change your COGS

When you buy the same item at different prices over a year, which cost do you assign to the units you sold? That choice — your inventory costing method — can change your COGS, your gross profit, and your tax bill, even though you sold exactly the same goods. There are three standard methods.

MethodAssumes you sell…COGS in rising prices
FIFO (first-in, first-out)Oldest stock firstLower — uses old, cheaper costs
LIFO (last-in, first-out)Newest stock firstHigher — uses recent, dearer costs
Weighted averageA blended-cost unitIn between FIFO and LIFO

Same goods sold, three different COGS figures — the method is an accounting choice, not a physical one.

  • FIFO assigns the cost of your earliest purchases to COGS, leaving recent (often higher) costs in ending inventory. In a period of rising prices this gives the lowest COGS and the highest reported profit — and the highest tax.
  • LIFO does the reverse: it charges your most recent, usually higher, costs to COGS, giving a higher COGS and lower taxable profit when prices rise. LIFO is permitted under US GAAP but banned under IFRS.
  • Weighted average blends every purchase price by quantity into one average cost per unit, landing COGS between the FIFO and LIFO figures and smoothing out price swings.
This calculator computes COGS from your period inventory totals, which works for any method — the method only changes the dollar values you feed into beginning inventory, purchases, and ending inventory. Pick one method and apply it consistently; switching methods to flatter profits is not allowed.
Ratio

COGS and gross margin

COGS only matters because of what sits next to it: gross profit and gross margin. Subtract COGS from revenue and you get gross profit; divide that by revenue and you get the gross margin — the share of every sales dollar left after the cost of the product. The COGS ratio is simply the mirror image: COGS ÷ revenue, the share that production ate.

gross profit = revenue COGS
gross margin = ( revenue COGS ) ÷ revenue × 100%
COGS ratio = COGS ÷ revenue × 100% (gross margin + COGS ratio = 100%)

Because gross margin is size-neutral, it is the number to compare across companies and over time. A falling gross margin — a rising COGS ratio — is an early warning that input costs are climbing faster than prices, long before it shows up in the bottom line. There is no universal 'good' COGS ratio: a grocer may run a COGS ratio of 70–80% on thin margins and high volume, while a software firm's is near zero. The only fair comparison is against direct peers and the company's own trend.

Inputs

Where to find the numbers for this calculator

Every figure this cost of goods sold calculator needs comes from a company's inventory records and its income statement.

  • Beginning inventory — the prior period's ending inventory, carried forward from last year's balance sheet or books.
  • Purchases — total inventory bought or produced this period, from your accounts payable, purchase ledger, or production cost records.
  • Ending inventory — the closing stock value from a physical count or a perpetual inventory system at the period's end.
  • Revenue (optional) — net sales for the period, the top line of the income statement, to also get gross profit and the COGS ratio.
For US tax, COGS is reported in Part III of Schedule C (sole proprietors) or on the equivalent inventory lines of the business return — using the very same beginning-inventory, purchases, and ending-inventory structure as this calculator.
Methodology

Formula and sources

This calculator uses the standard inventory-accounting definition of cost of goods sold — COGS = beginning inventory + purchases − ending inventory — together with gross profit = revenue − COGS and the COGS ratio = COGS ÷ revenue. The formula, the components included in COGS, and the FIFO / LIFO / weighted-average distinction follow the conventions set out in US GAAP, the IRS instructions for reporting cost of goods sold, and standard corporate-finance references.

Investopedia — Cost of Goods Sold (COGS): Definition and How to Calculate It.
Questions

Frequently asked questions about the free cost of goods sold calculator

A cost of goods sold calculator is a free online tool that helps you calculate cost of goods sold (COGS) from beginning inventory, purchases, and ending inventory — plus gross profit and the COGS ratio when you add revenue. COGS is the direct cost of the goods a business sold in a period. COGS = beginning inventory + purchases − ending inventory; gross profit = revenue − COGS. It runs entirely in your browser with instant results and no sign-up.
COGS = beginning inventory + purchases − ending inventory. Take the value of stock you held at the start of the period, add everything you bought or produced during it, and subtract the value of stock still unsold at the end — whatever is missing was sold, and its cost is your COGS. For example, $20,000 of beginning inventory plus $80,000 of purchases minus $15,000 of ending inventory gives a COGS of $85,000.
COGS includes only the direct costs of producing the goods you sold: raw materials (the components that physically go into the product), direct labour (the wages of the people who make it), and manufacturing overhead (factory utilities, equipment depreciation, and maintenance on the production line). Costs that keep the business running but aren't tied to making the product — office rent, admin salaries, marketing — are operating expenses, not COGS.
COGS holds the direct costs of making and selling the product; operating expenses (often shown as SG&A) hold the indirect costs of running the company — rent, administrative salaries, marketing, and the like. A simple test: if a cost would still exist even if you produced nothing this period, it is an operating expense, not COGS. COGS sits above gross profit on the income statement; operating expenses sit below it.
Yes — COGS is an expense on the income statement, but a special one. Inventory starts life as an asset on the balance sheet; it only becomes COGS at the moment an item is sold. That's why COGS tracks sales rather than spending: buying stock you haven't sold yet doesn't raise COGS, it raises inventory.
In normal trading, no — you can't sell a negative quantity of goods, so a real COGS figure is zero or positive. The formula can return a negative number only when ending inventory exceeds beginning inventory plus purchases, which signals a data error (a miscount or a missing purchases entry) rather than a genuine result. Recheck your inventory figures if that happens.
They change which purchase costs get assigned to the goods you sold. In a period of rising prices, FIFO (first-in, first-out) uses your oldest, cheaper costs and gives the lowest COGS and highest profit; LIFO (last-in, first-out) uses your most recent, dearer costs and gives a higher COGS and lower taxable profit; weighted average blends all purchase prices and lands in between. Same goods sold, three different COGS figures — pick one method and apply it consistently.
About

About this cost of goods sold calculator

This cost of goods sold calculator runs entirely in your browser. Every figure you enter stays on your device — nothing is sent to a server, logged, or shared. It applies the standard inventory formula COGS = beginning inventory + purchases − ending inventory, then subtracts COGS from revenue for gross profit and divides COGS by revenue for the COGS ratio, updating instantly as you type.

Calculators Cloud offers 400+ free tools with no sign-up. The whole Business calculators shelf includes Profit margin, Markup, and EBIT tools alongside this one. Or browse the full calculator directory.

Want a calculator built for your business?

Customize any of our 400+ tools to match your brand, or commission a new one tailored to how your business actually calculates — pricing, payroll, quotes, anything. Deployed on your domain, math runs in your visitors' browsers.