Skip to content
CalculatorAtlas

Cost of Goods Sold Calculator

Tested

COGS from inventory and purchases.

Tested, not yet published. The formula for this calculator is implemented and passes its automated checks. This page stays non-indexable until it is reviewed and published.

$
$
$

Results

Enter your values and press Calculate. Results appear here.

  • • Result

Quick answer

Cost of goods sold = beginning inventory + purchases − ending inventory. $20,000 + $85,000 − $18,000 = $87,000.

Enter beginning inventory, purchases and ending inventory. The calculator returns COGS for the period.

Related tools: Marginal Cost Calculator: Extra cost of producing additional units. Opportunity Cost Calculator: Value given up by choosing one option over another. Meeting Cost Calculator: Cost of a meeting from attendees and hourly cost.

How to use the Cost of Goods Sold Calculator

  1. Enter beginning inventory ($) (0 or more).
  2. Enter purchases ($) (0 or more).
  3. Enter ending inventory ($) (0 or more).
  4. Press Calculate to see the result, and use Reset to start again.
Inputs of the Cost of Goods Sold Calculator
InputWhat to enterAllowed values
Beginning inventoryA number, in $≥ 0
PurchasesA number, in $≥ 0
Ending inventoryA number, in $≥ 0

Formula and method

Formula

COGS = beginning inventory + purchases − ending inventory

IEEE-754 double precision; shown to the decimals indicated.

Periodic inventory method.

Worked examples

These examples are verified: each one is an automated test case that the live calculator must reproduce exactly.

Example 1

Inputs: Beginning inventory = 20000; Purchases = 85000; Ending inventory = 18000.

Results of example 1
ResultValue
COGS$87,000.00

Example 2

Inputs: Beginning inventory = 0; Purchases = 5000; Ending inventory = 1200.

Results of example 2
ResultValue
COGS$3,800.00

The first line is the headline result (cOGS). IEEE-754 double precision; shown to the decimals indicated.

The logic

Beginning inventory plus purchases is the stock available to sell, $105,000 here. What is left at the end of the period, $18,000, was not sold, so the rest, $87,000, was. COGS is subtracted from revenue to give gross profit.

What it leaves out

Direct labour and manufacturing overhead are part of COGS for manufacturers but are not inputs here. Inventory valuation (FIFO, LIFO or average cost) changes the inventory figures and therefore COGS. Ending inventory cannot exceed the goods available.

How the result changes with beginning inventory

Holding every other input at the first worked example, this table changes only beginning inventory. It shows how sensitive the answer is to that one value; each row was produced by running this calculator.

How the result changes with beginning inventory
Beginning inventoryCOGS
10000$77,000.00
20000$87,000.00
40000$107,000.00
80000$147,000.00

What happens with invalid input

These messages are produced by the calculator itself, so you know what to fix.

  • Beginning inventory: entering "-1" shows "Beginning inventory must be at least 0." beside that field and no result.
  • Ending inventory: entering "5" shows "Ending inventory cannot exceed beginning inventory plus purchases." beside that field and no result.

Choosing between the Cost of Goods Sold Calculator and similar calculators

Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.

Choosing between the Cost of Goods Sold Calculator and similar calculators
CalculatorYou enterIt returns
[Marginal Cost Calculator](/business/marginal-cost/)total cost before, total cost after and quantity beforeMarginal cost
[Opportunity Cost Calculator](/business/opportunity-cost/)return of the option you gave up and return of the option you choseOpportunity cost
[Meeting Cost Calculator](/business/meeting-cost-calculator/)attendees, average cost per person per hour and durationMeeting cost
[Payroll Cost Calculator](/business/payroll-cost-calculator/)employees, average annual salary and taxes and benefits on top of salaryAnnual payroll cost
[Cost Per Acquisition Calculator](/business/cost-per-acquisition-calculator/)marketing and sales spend and new customers or conversionsCost per acquisition

Background: business metrics

Business ratios depend on exactly which costs and revenues you include, so read each page's definition. Two common checks: break-even units = fixed costs ÷ (price − variable cost per unit), so $50,000 of fixed costs with a $10 price and $5 variable cost breaks even at 10,000 units; and net profit margin = net profit ÷ revenue, so $20,000 profit on $100,000 revenue is 20%.

Return on investment ignores time: 20% over five years is far less impressive than 20% in one, so compare returns over the same period.

Assumptions and limitations

  • Ending inventory cannot exceed what was available

If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for beginning inventory and ending inventory to confirm this.

Frequently asked questions

Is COGS an expense?

Yes, it is deducted from revenue on the income statement.

Does it include marketing?

No, only costs directly tied to goods sold.

How does it relate to gross margin?

Gross profit is revenue minus COGS.

What does the Cost of Goods Sold Calculator calculate?

COGS from inventory and purchases. It returns COGS.

What formula does the Cost of Goods Sold Calculator use?

COGS = beginning inventory + purchases − ending inventory. Periodic inventory method.

What do I need to enter in the cost of Goods Sold Calculator?

You enter Beginning inventory ($), Purchases ($) and Ending inventory ($).

How is the result rounded or limited?

IEEE-754 double precision; shown to the decimals indicated. Ending inventory cannot exceed what was available.

What is an example of a cost of Goods Sold result?

With beginning inventory 20000, purchases 85000 and ending inventory 18000, the cOGS is $87,000.00.

Where does the method come from?

The method follows: OpenStax, Principles of Accounting, Volume 1: Financial Accounting (Rice University).

Sources

  • OpenStax, Principles of Accounting, Volume 1: Financial Accounting (Rice University)

Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.