Cost of Goods Sold Calculator

The cost of goods sold calculator works out the direct cost of the products a business sold during a period, the figure subtracted from revenue to reach gross profit. The method is the standard inventory relationship: cost of goods sold equals beginning inventory plus purchases during the period minus ending inventory. The logic is intuitive, whatever was available to sell but is no longer on hand must have been sold, so its cost belongs to the period. Inventory cost includes the purchase price plus direct costs of getting goods ready to sell, such as freight in, and for manufacturers the direct materials, labour and factory overhead; it excludes selling and administrative costs, which sit below gross profit. The cost flow assumption (FIFO, LIFO or weighted average) changes the dollar value assigned to ending inventory and therefore to COGS when prices vary, though the formula itself is unchanged. Enter your own beginning inventory, purchases and ending inventory to measure COGS, work out a gross margin, or check a line on an income statement. Every figure here is computed deterministically from the formula shown in full below, with a worked example that reconciles exactly to the calculator.

Cost of goods sold equals beginning inventory plus purchases minus ending inventory: COGS = beginning + purchases - ending. Starting with $50,000.00, buying $200,000.00 and ending with $40,000.00 gives COGS of $210,000.00.

Source: US Securities and Exchange Commission, Investor.gov. As at 25 June 2026.

Inventory at start of period
Inventory bought in the period
Inventory still on hand
Goods available for sale--
Less ending inventory--
Cost of goods sold--

Cost of goods sold formula

COGS = BI + P - EI
BI = beginning inventory
P = purchases during the period
EI = ending inventory

Beginning inventory plus purchases is the goods available for sale. Subtracting what is still on hand at the end leaves the cost of what was sold, which is COGS.

Worked example

A retailer starts with 50,000 dollars of inventory, buys 200,000 dollars during the year, and ends with 40,000 dollars on hand.

  1. Goods available = 50,000 + 200,000 = 250,000
  2. Less ending inventory = 250,000 - 40,000
  3. COGS = 210,000

Cost of goods sold is 210,000 dollars. These are the calculator's default inputs, so the result above matches the widget exactly.

COGS at different ending inventories

COGS with 50,000 beginning and 200,000 in purchases.

BeginningPurchasesEndingCOGS
50,000200,00030,000220,000.00
50,000200,00040,000210,000.00
50,000200,00060,000190,000.00

Inventory accounting basics: US Securities and Exchange Commission, Investor.gov.

Cost of goods sold calculator: frequently asked questions

What is cost of goods sold?

Cost of goods sold, or COGS, is the direct cost of the products a business sold during a period. It includes the cost of the inventory that left the shelves, found from beginning inventory plus purchases minus ending inventory. COGS is subtracted from revenue to get gross profit, so it directly drives a company's margins.

How do I calculate COGS?

Add beginning inventory to purchases during the period, then subtract ending inventory. If you start with 50,000 dollars of inventory, buy 200,000 dollars more, and end with 40,000 dollars, COGS is 50,000 plus 200,000 minus 40,000, which equals 210,000 dollars. The logic is that whatever was available but not still on hand must have been sold.

What is included in inventory cost?

Inventory cost includes the purchase price of goods plus the direct costs of getting them ready to sell, such as freight in, and for manufacturers the direct materials, direct labour and factory overhead. It excludes selling, general and administrative expenses, which are operating expenses below gross profit rather than part of COGS.

How does COGS affect gross profit?

Gross profit equals revenue minus cost of goods sold, so a higher COGS means a lower gross profit and gross margin. Controlling purchase costs, reducing waste and managing inventory all lower COGS and lift margins. Because COGS varies with sales volume, it is a key driver of profitability as a business grows.

Does the inventory method change COGS?

Yes. The cost flow assumption, such as FIFO, LIFO or weighted average, changes which costs are assigned to ending inventory and which to COGS when purchase prices vary. The beginning plus purchases minus ending formula still holds, but the dollar value of ending inventory, and therefore COGS, depends on the method chosen.

Official sources

Reviewed by the CalculatorHub team, edited by James Graham, 25 June 2026. See our methodology. This is general information, not financial, tax, legal or investment advice.