Cost of Goods Sold (COGS) Calculator

Cost of goods sold is the cost of the inventory that actually left your shelves this period. This calculator builds it the way an accountant does: start with beginning inventory, add everything you bought or produced, then subtract what is still on hand at the count. Enter purchases, freight-in, returns and discounts for a reseller, or direct materials, direct labor, overhead and work-in-process balances for a manufacturer. You get COGS, cost of goods manufactured, gross profit and gross margin, plus the full schedule in the layout your tax return expects.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Beginning inventoryThe inventory balance carried in from the last period — the prior period's ending inventory.42000 $
Gross purchasesEverything you bought for resale at invoice price, before freight, returns or discounts.310000 $
Freight-inInbound shipping and handling to get goods to your door — part of inventory cost, not a selling expense.8500 $
Purchase returns and allowancesEnter as a positive number; goods you sent back or price allowances vendors granted you.6200 $
Purchase discounts takenEarly-payment discounts such as 2/10 net 30 that you actually took. Enter as a positive number.4300 $
Ending inventoryThe physical count at period end, valued at cost under your cost-flow method.38500 $
Net sales revenueSales net of returns and allowances, so gross profit and gross margin can be derived.520000 $
Direct materials usedRaw materials issued to production: beginning raw materials plus purchases minus ending raw materials.0 $
Direct laborWages and payroll taxes for people who physically make the product, including their fringe benefits.0 $
Manufacturing overhead appliedIndirect factory cost charged to jobs — usually your predetermined rate times the actual activity base.0 $
Beginning work in processCost sitting in partly finished units at the start of the period.0 $
Ending work in processCost still in partly finished units at period end; it stays on the balance sheet.0 $

It returns

  • Cost of goods sold — The inventory cost that leaves the balance sheet and hits the income statement this period.
  • Gross profit
  • Gross margin
  • Net purchases
  • Cost of goods manufactured
  • Cost of goods available for sale

The formula

COGS=I0+P+COGMI1
COGM=DM+DL+MOH+WIP0WIP1
GM%=RCOGSR×100

In plain text: COGS = Beginning inventory + Net purchases + Cost of goods manufactured − Ending inventory

  • COGSCost of goods sold for the period ($)
  • I₀Beginning inventory of merchandise or finished goods ($)
  • PNet purchases: gross purchases + freight-in − returns − discounts ($)
  • COGMCost of goods manufactured (zero for a pure reseller) ($)
  • I₁Ending inventory at the physical count, valued at cost ($)

The identity holds under any cost-flow assumption. FIFO, LIFO and weighted average change how you value I₁, and therefore COGS, but not the structure of the equation.

Updated Category Inventory, Receivables & Asset Accounting Verified against published test cases Reading time 11 min

What cost of goods sold actually measures

Cost of goods sold is the cost of inventory that left the business this period, not the cost of inventory you bought this period. Those two numbers are almost never equal, and confusing them is the most common error on a small-business income statement.

Inventory is an asset. When you buy or build a unit, its cost sits on the balance sheet and nothing hits the income statement. The moment the unit sells, that cost moves out of inventory and becomes an expense. The cost of the thing and the revenue from the thing land in the same period, which is the matching principle in its purest form.

Because inventory acts as a reservoir, the arithmetic is a flow calculation: whatever came in, minus whatever is still there, must have gone out. Hence the identity every accountant reaches for. Notice what carries the weight in it — ending inventory. Under a periodic system COGS is never measured directly; it is a residual computed from a physical count, so every ounce of counting error lands squarely in profit.

COGS drives three decisions. It sets gross profit, the money available to cover every other cost you have. It sets taxable income, because the IRS makes producers and resellers capitalise inventory cost and deduct it only as goods are sold. And it feeds the ratios lenders read: gross margin, inventory turnover and days inventory outstanding.

The formula explained, line by line

Start with the reseller version. Beginning inventory is not an estimate — it is last period's ending inventory, unchanged. If the two disagree you have a cut-off error, and every ratio downstream is wrong.

Net purchases is where the judgement sits. Invoice price is only the starting point. You add freight-in, because a cost incurred to bring goods to their present location and condition is inventory cost under both ASC 330 and IAS 2. You subtract purchase returns and allowances for goods sent back or concessions received, and purchase discounts you actually took, such as the 2% on a 2/10 net 30 invoice. What you do not subtract is freight-out: shipping to the customer is a selling cost that belongs below the gross profit line.

A manufacturer adds a second stage, because goods are created rather than bought. Three pools flow into production: direct materials used (beginning raw materials plus raw material purchases minus ending raw materials), direct labor for the people who physically transform the product, and manufacturing overhead applied — indirect factory cost charged to jobs through a predetermined overhead rate. Those three sum to total manufacturing cost.

But not everything you started got finished. Adding beginning work in process and subtracting ending work in process converts total manufacturing cost into cost of goods manufactured — the cost of units that crossed the finish line. COGM then behaves exactly as purchases do for a reseller: an addition to finished goods, run through the same beginning-plus-additions-minus-ending logic.

The structure is deliberately independent of your cost-flow assumption. Valuing the closing count with FIFO, LIFO or weighted average cost changes the number you plug in for ending inventory. It does not change the equation.

Worked example: a wholesaler's year in five lines

A plumbing-supply wholesaler closes its year with these books: opening inventory $42,000; gross purchases $310,000; inbound freight $8,500; goods returned to vendors $6,200; early-payment discounts taken $4,300; the December count values remaining stock at $38,500. Net sales were $520,000.

  1. Net purchases. $310,000 + $8,500 = $318,500 of gross cost delivered. Subtract $6,200 of returns and $4,300 of discounts: $318,500 − $10,500 = $308,000.
  2. Cost of goods available for sale. $42,000 opening stock + $308,000 net purchases = $350,000. This is the total cost the business had available to sell during the year.
  3. Subtract what is left. $350,000 − $38,500 = $311,500 cost of goods sold.
  4. Gross profit. $520,000 − $311,500 = $208,500.
  5. Gross margin. $208,500 ÷ $520,000 = 0.40096, or 40.1%.

Now feel the leverage in step 3. Suppose the count missed one pallet worth $6,000, so ending inventory is recorded at $32,500. COGS rises to $317,500 and gross profit falls to $202,500 — a 2.9% hit to reported profit from a $6,000 miscount, which is only 1.7% of the $350,000 of goods available for sale. And it does not stop there: understated ending inventory becomes understated beginning inventory next year, overstating next year's profit by the same $6,000. Inventory errors are always two-period errors.

Run the same business as a manufacturer. Opening finished goods $25,000; direct materials used $120,000; direct labor $90,000; overhead applied $60,000; opening WIP $15,000; closing WIP $12,000; closing finished goods $30,000. Total manufacturing cost is $270,000. COGM is $270,000 + $15,000 − $12,000 = $273,000. COGS is $25,000 + $273,000 − $30,000 = $268,000. Two inventory accounts, two applications of one identity.

How to read the result

Read COGS through gross margin, and read gross margin against your own history first. A single period's margin tells you almost nothing; four steady quarters and then a two-point drop tells you a great deal. Compare against outside benchmarks only within a tight industry definition, because two competitors can report different margins purely because one puts inbound freight and warehouse labour in COGS and the other does not.

Three diagnostics are worth running every close. Margin versus mix: if margin falls while product mix is unchanged, the cause is pricing or purchase cost. COGS versus purchases: if COGS rose faster than purchases you liquidated inventory, and if it rose slower you built stock — neither is inherently bad, but both move cash, which is why this number appears in cash conversion cycle work. Margin versus turnover: a low margin with fast turnover is a viable model, a low margin with slow turnover usually is not.

Watch for spurious margin improvement. A manufacturer that builds more units than it sells pushes fixed overhead into ending inventory instead of COGS, lifting reported gross profit without a single extra sale. Under absorption costing that is entirely legal and entirely misleading, which is why analysts compare production volume to sales volume before trusting a margin trend.

Same purchases, three cost-flow assumptions

Beginning inventory 100 units at $10, then 200 units at $12, then 150 units at $14. Total available: 450 units costing $5,500. Sold 300 units at $20 each, so revenue is $6,000 and 150 units remain.
MethodEnding inventoryCost of goods soldGross profitGross margin
FIFO$2,100$3,400$2,60043.3%
Weighted average$1,833$3,667$2,33338.9%
LIFO$1,600$3,900$2,10035.0%

Identical physical facts, three legal answers, a $500 spread in reported profit. FIFO assigns the oldest $3,400 to COGS; LIFO assigns the newest $3,900; weighted average uses $5,500 ÷ 450 = $12.22 per unit. LIFO is permitted under US GAAP but prohibited by IAS 2.

Which rules govern this number

US GAAP: FASB ASC 330, Inventory, measures inventory at cost — the expenditures and charges incurred to bring an article to its present condition and location. Inventory not measured under LIFO or the retail method is then carried at the lower of cost or net realisable value.

IFRS: IAS 2, Inventories, requires cost to include purchase cost, conversion cost and other costs of bringing inventory to its present location and condition, measured with FIFO or weighted average cost. LIFO is not permitted.

US tax: IRC §471 requires inventories where they are needed to clearly determine income, and §263A forces producers and many resellers to capitalise indirect costs that book accounting might expense. Small businesses meeting the §448(c) average-gross-receipts test are exempt from §263A; that threshold is indexed for inflation, so check the current figure in IRS Publication 538.

Mistakes that corrupt a COGS figure

  • Using purchases as COGS. Legitimate only when beginning and ending inventory are equal, which for a real business means never. Enter both balances.
  • Leaving freight-in out. Inbound freight is inventory cost under ASC 330, IAS 2 and §263A. Expensing it understates inventory and overstates COGS in the year of purchase.
  • Putting freight-out in COGS. Shipping to customers is a distribution cost. Some companies do present it inside cost of revenue, but then they should say so, because it moves the margin.
  • Counting consignment goods. Stock held on consignment belongs to the consignor; counting it inflates ending inventory and understates COGS.
  • Missing goods in transit. FOB shipping point means title passed at the vendor's dock, so it is yours and must be counted even though it is on a truck. FOB destination means it is not.
  • Skipping the lower-of-cost-or-net-realisable-value write-down. Obsolete stock carried at cost overstates ending inventory and understates COGS until someone finally writes it off.
  • Ignoring under- or over-applied overhead. The variance has to be cleared at year end, usually to COGS, or your gross margin drifts away from reality.

Periodic and perpetual systems reach the same place differently

A periodic system computes COGS once, as the residual described above, from a physical count. It is cheap, and it is what this calculator models. Its weakness is that shrinkage — theft, breakage, spoilage, mis-shipment — disappears silently into COGS, because anything missing from the count is presumed sold.

A perpetual system posts a cost-of-sales entry with every sale, so the ledger is always current. The advantage is diagnostic: at the count you compare book inventory to actual, and the difference is measured shrinkage rather than an invisible add-on to COGS. If you run perpetual, use this calculator as a reasonableness check on the total your point-of-sale system produced and investigate a gap of more than a percent or two.

One point surprises people: under FIFO, periodic and perpetual give identical COGS and ending inventory, because costing the oldest units first produces the same layer assignment whether you do it per transaction or once at year end. Under LIFO and weighted average they diverge, since what counts as "most recent" or "average" depends on when you look.

Where COGS fits, and when to use a different tool

COGS sits at the top of a chain. Subtract it from revenue for gross profit, then work down through operating expenses to operating profit and net profit margin. Divide COGS by average inventory and you have inventory turnover, which converts into days on hand. Nearly every cost-side ratio starts here.

Use a different tool when the question changes. To derive ending inventory rather than assume it, work the layers with the FIFO, LIFO or weighted-average calculators. To find the volume that covers fixed costs, you want contribution margin and break-even — and note that contribution margin uses variable cost while COGS under absorption costing includes fixed factory overhead. Treating those two as interchangeable is a classic managerial-accounting error.

Service businesses with no inventory report "cost of revenue" instead: direct labour and directly attributable delivery cost, with no ending-inventory term. The gross margin idea still works; the inventory identity does not apply.

Key terms

Cost of goods available for sale
Beginning inventory plus all additions. The pool split between ending inventory and COGS.
Cost of goods manufactured (COGM)
The cost of units completed in the period and transferred out of work in process into finished goods.
Absorption costing
The required GAAP and tax approach, in which fixed factory overhead is capitalised into inventory rather than expensed as incurred.
Shrinkage
The gap between book inventory and counted inventory. Invisible in a periodic system; measurable in a perpetual one.

Frequently asked questions

What is included in cost of goods sold?

Every cost of getting the units you sold into saleable condition and location: the purchase price of the goods, inbound freight, duties and non-recoverable taxes, and for a manufacturer, direct materials, direct labor and applied factory overhead. What is excluded is anything that happens after the goods are ready to sell — sales commissions, advertising, outbound shipping, general administration and interest. If the cost would have been incurred whether or not you made the unit, it is usually not inventory cost.

Is cost of sales the same as cost of goods sold?

In most filings, yes. Companies with physical inventory usually write "cost of goods sold"; retailers, service firms and software companies more often write "cost of sales" or "cost of revenue". The captions are not defined terms, so read the accounting policy note before you compare two companies: one may include distribution and warehousing inside cost of sales while the other reports those in operating expenses, which shifts gross margin by several points without any economic difference.

Does outbound shipping to my customer go in COGS?

No — outbound freight is a selling and distribution expense that belongs below the gross profit line, while inbound freight is inventory cost and does belong in COGS. Some companies present outbound freight within cost of revenue, which is acceptable if disclosed consistently, but the default treatment separates the two. Keep them in separate accounts so you can present either way and still compare periods.

What if I do not know my ending inventory?

Then you cannot compute COGS accurately, and you should count. If a count is impossible mid-year, the gross profit method gives a usable estimate: apply your historical gross margin to sales to estimate COGS, then back into ending inventory as goods available for sale minus that estimate. It is accepted for interim reporting and insurance claims, but it assumes your margin has not moved.

Does COGS include labor?

It includes direct labor for anyone who physically makes or assembles the product, with their payroll taxes and fringe benefits. Factory supervision, inspection and maintenance go in as overhead. Sales staff, delivery drivers and office administration do not. A pure reseller normally has no labour in COGS at all, which is why retail and manufacturing gross margins are not directly comparable.

Where does COGS appear on a US tax return?

Corporations and partnerships compute it on Form 1125-A, which follows the same lines as this calculator: beginning inventory, purchases, cost of labor, additional §263A costs, other costs, less ending inventory. Sole proprietors use Part III of Schedule C. Both forms ask which valuation method you use and whether it changed, because a method change generally needs IRS consent on Form 3115.

Why did my COGS rise when purchases stayed flat?

Because you sold from stock. COGS equals purchases plus the decrease in inventory, so drawing inventory down by $20,000 with purchases unchanged raises COGS by $20,000. The mirror case is equally common: building inventory suppresses COGS and flatters gross profit even though nothing about pricing improved. Always read the inventory movement alongside the margin — that is the number that reconciles profit to cash.

What gross margin should I expect?

There is no single right answer, and any figure quoted without an industry attached is noise. Grocery and commodity distribution run thin margins at very fast turnover; branded manufacturing sits far higher on a slower cycle. The useful test is internal: your trailing four quarters, your product mix, and whether margin times turnover still covers your operating cost base.

References