Calculate cost of goods sold with the periodic inventory formula: beginning inventory plus purchases and direct costs, minus ending inventory. Add your revenue to also see gross profit, gross margin and how fast your inventory turns.
Last updated:
Inventory
$
$
Value of stock on hand at the end of the period.
Purchases
$
$
$
Subtracted from purchases.
Direct production costs (optional)
$
$
Factory overhead, packaging, other costs to produce.
Sales (optional)
$
Leave empty to skip gross profit.
365 for a year, 90 for a quarter, 30 for a month.
Enter your values to see the result.
Advertisement
Advertisement
How to use the Cost of Goods Sold Calculator
Enter beginning inventory: the value of inventory on hand at the start of the period (last period's ending inventory).
Add purchases and freight-in, and subtract purchase returns and discounts.
Add direct labor and other direct costs if you manufacture or assemble products.
Enter ending inventory from your stock count at the end of the period.
Optionally enter revenue to see gross profit, gross margin and inventory turnover.
The cost of goods sold formula
COGS = Beginning inventory + Net purchases + Direct costs − Ending inventory
Net purchases = purchases + freight-in − purchase returns and allowances − purchase discounts.
Direct costs (manufacturers): direct labor and manufacturing overhead used to make the goods.
Goods available for sale = beginning inventory + net purchases + direct costs. Part of it was sold (COGS) and the rest is still on the shelf (ending inventory).
Example: $25,000 beginning inventory + $81,500 net purchases ($80,000 + $3,000 freight-in − $1,500 returns) + $12,000 direct labor + $6,000 overhead = $124,500 available. With $30,000 left at year end, COGS = $94,500. On $160,000 of revenue, gross profit is $65,500, a 40.9% gross margin.
Service businesses often report "cost of revenue" or "cost of services" instead, made up of the direct labor and materials needed to deliver the service.
FIFO, LIFO and weighted average
When unit costs change during the year, the inventory method decides which costs stay in ending inventory. Under FIFO the oldest costs go to COGS first; under LIFO (allowed under US GAAP, not under IFRS) the newest costs go first; weighted average uses the average cost of all units available. Value your ending inventory with your chosen method and enter it here.
Frequently asked questions
What is the COGS formula?
Cost of goods sold = beginning inventory + purchases − ending inventory. Freight-in is added to purchases, purchase returns and discounts are subtracted, and manufacturers also add direct labor and manufacturing overhead. The result is the cost of the inventory that was actually sold during the period.
What costs are included in COGS?
COGS includes the direct cost of products sold: the purchase price of goods or raw materials, inbound freight, direct labor to make the product and manufacturing overhead such as factory utilities. It excludes selling, marketing, administrative costs, outbound shipping in many cases, and interest, which are operating or non-operating expenses.
Why can COGS not be negative?
If ending inventory is larger than everything available for sale (beginning inventory + purchases + direct costs), the numbers do not reconcile. Usually a purchase is missing, ending inventory was over-counted, or the periods do not match.
How do I calculate gross profit and gross margin from COGS?
Gross profit = revenue − COGS. Gross margin = gross profit ÷ revenue × 100. With revenue of $160,000 and COGS of $94,500, gross profit is $65,500 and the gross margin is about 40.9%.
Does the inventory method (FIFO, LIFO, average) change COGS?
Yes. The method decides how ending inventory is valued when prices change. In a period of rising prices, FIFO leaves the newest, more expensive units in ending inventory, so COGS is lower; LIFO does the opposite. This calculator takes your ending inventory value as given, whichever method you use.
What is inventory turnover?
Inventory turnover = COGS ÷ average inventory, where average inventory = (beginning + ending) ÷ 2. Days in inventory = days in the period ÷ turnover, the average number of days an item sits in stock before it is sold.
Is my data stored anywhere?
No. The calculation runs entirely in your browser and nothing is uploaded.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.