Cost of Goods Sold Calculator

Calculate Cost of Goods Sold from beginning inventory, purchases, and ending inventory, then see the gross profit and gross margin those goods produced against net sales.

Quick Facts

Formula
COGS = Beginning Inventory + Purchases − Ending Inventory
Purchases include freight-in and production costs, net of returns and discounts.
Gross margin
Gross Profit ÷ Net Sales × 100
Gross Profit = Net Sales − COGS, the revenue left before operating expenses.

Your Results

Calculated
Cost of Goods Sold
-
Beginning inventory + purchases − ending inventory
Gross profit
-
Net sales − COGS
Gross margin
-
Gross profit as % of net sales
COGS ratio
-
COGS as % of net sales

Ready

Enter beginning inventory, purchases, ending inventory, and net sales, then press Calculate.

How the Cost of Goods Sold Calculator works

Cost of Goods Sold (COGS) is the direct cost of the inventory a business actually sold during a period — the raw materials, merchandise, and direct production costs, but not overhead like rent or marketing. It is the figure subtracted from revenue on an income statement to get gross profit, so getting it right matters for pricing, tax reporting, and margin analysis.

The formula

This calculator uses the standard periodic-inventory formula:

COGS = Beginning Inventory + Purchases − Ending Inventory

Beginning inventory is the value of unsold stock on hand at the start of the period. Purchases is everything added to inventory during the period — merchandise or raw materials bought, freight-in, and direct production costs — net of any purchase returns, allowances, or discounts. Ending inventory is the value of unsold stock left at the close of the period. The logic is simple: whatever you started with plus whatever you added, minus whatever is left over, must be what you sold.

Worked example

A retailer starts the quarter with $50,000 of inventory, purchases $120,000 of additional merchandise, and ends the quarter with $35,000 still on the shelves. COGS = $50,000 + $120,000 − $35,000 = $135,000. If net sales for the quarter were $250,000, gross profit is $250,000 − $135,000 = $115,000, and gross margin is $115,000 / $250,000 × 100 = 46.0%.

Gross profit and gross margin

Once COGS is known, two related figures follow directly: Gross Profit = Net Sales − COGS, and Gross Margin (%) = Gross Profit ÷ Net Sales × 100. Gross margin shows what share of each sales dollar remains after covering the direct cost of the goods themselves, before operating expenses, interest, and taxes are subtracted. The calculator also reports the COGS ratio (COGS ÷ Net Sales × 100), the mirror image of gross margin, which is useful for tracking how the direct cost of goods trends as a share of revenue over time.

What moves COGS

  • Ending inventory: a lower ending inventory (more sold through, or less carried over) raises COGS for the period, all else equal.
  • Purchases: the more inventory added during the period, the higher goods available for sale — and, if it isn't left unsold, the higher COGS.
  • Inventory valuation method: businesses that use FIFO, LIFO, or weighted-average costing can get different beginning and ending inventory values from the same physical stock, which changes COGS even when nothing else about the period differs.

Scope and assumptions

This calculator uses the periodic method common in general financial reporting and assumes the beginning inventory, purchases, and ending inventory figures you enter are already valued consistently (same costing method, same units). It does not separate cost of goods manufactured versus cost of goods purchased, and it is a computational tool, not tax or accounting advice — for GAAP, IFRS, or tax-specific inventory treatment, confirm the figures with an accountant.

Frequently Asked Questions

What is the formula for Cost of Goods Sold?
COGS = Beginning Inventory + Purchases During the Period − Ending Inventory. Beginning and ending inventory are the value of unsold stock at the start and end of the period, and purchases include everything added to inventory in between, such as freight-in and production costs, net of any returns or discounts.
What counts as Purchases during the period?
Purchases is the total cost added to inventory during the period: merchandise or raw materials bought, freight-in and other costs to get goods ready for sale, and direct manufacturing costs if you produce what you sell, minus any purchase returns, allowances, or discounts you received.
How is gross profit and gross margin calculated from COGS?
Gross Profit = Net Sales − COGS, and Gross Margin (%) = Gross Profit ÷ Net Sales × 100. These figures show how much revenue is left after covering the direct cost of the goods sold, before operating expenses, interest, and taxes are subtracted.
Why can't ending inventory exceed beginning inventory plus purchases?
Beginning inventory plus purchases equals the total goods available for sale during the period. You cannot end the period with more inventory than you started with and added, so if ending inventory is entered higher than that total, the calculator flags the input as invalid rather than showing a negative COGS.