Skip to content

01Free Online Calculator + Excel Workbook

COGS Calculator: Cost of Goods Sold Formula, FIFO, LIFO and Average Cost

Calculate cost of goods sold with the IRS formula, compare FIFO, LIFO and average cost for five purchase lots, and get gross margin. Free Excel with formulas.

Cost of goods sold worksheet with FIFO, LIFO and average cost
Cost of goods sold · FIFO, LIFO, average cost · gross margin

COGS Calculator

Goods available for sale (line 40)$321,095.00
Cost of goods sold (line 42)$288,140.00
Gross profit$96,920.00
Gross margin25.17%Gross profit ÷ net sales
COGS as a share of sales74.83%

Applies the Schedule C cost of goods sold lines and single-period FIFO, LIFO and average cost; tax LIFO uses yearly layers and needs Form 970, and the uniform capitalization rules can add costs, so check your return with your tax preparer.

Cost of goods sold (COGS) is what the goods you sold during the year cost you: beginning inventory, plus purchases and the costs of making the goods, minus the inventory left at the end of the year. IRS Publication 334 works an example: $37,845 beginning inventory plus $283,250 of purchases (after $2,650 of items withdrawn for personal use) gives $321,095 of goods available for sale; minus $32,955 ending inventory, cost of goods sold is $288,140. With net receipts of $385,060, gross profit is $96,920, a gross margin of 25.17% (computed).

The calculator does that formula in the first mode and, in the second, compares FIFO, LIFO and average cost for up to five purchase lots, so you can see how the inventory method changes COGS and ending inventory. The Excel workbook has both sheets with live formulas.

What the IRS Counts in Cost of Goods Sold

Schedule C (sole proprietors)Form 1125-A (corporations, partnerships)What goes in
Line 35: inventory at beginning of yearLine 1Usually last year's closing inventory; for a manufacturer, raw materials, work in process, finished goods and materials used in manufacturing
Line 36: purchases less cost of items withdrawn for personal useLine 2: purchasesMerchandise bought for sale, or raw materials and parts; at the prices you actually pay after trade discounts, minus returns and allowances
Line 37: cost of laborLine 3Direct and indirect labor in manufacturing or mining; not amounts paid to yourself; small merchandisers usually have none
Line 38: materials and suppliesNo separate lineMaterials and supplies used in manufacturing the goods
Line 39: other costsLine 5: other costs (line 4 holds additional section 263A costs)Containers that are part of the product, freight-in, and overhead of the manufacturing operation such as rent, power, insurance and depreciation
Line 40: total of lines 35 to 39Line 6Cost of goods available for sale
Line 41: inventory at end of yearLine 7Closing inventory, which becomes next year's beginning inventory
Line 42: cost of goods soldLine 8Line 40 minus line 41, carried to Schedule C line 4 or the return's COGS line

Line descriptions from IRS Publication 334, chapter 6, and Form 1125-A. Pub. 334 adds that this chapter does not apply to a personal service business, such as a doctor, lawyer, carpenter or painter, unless it also sells the materials it uses. Selling and administrative costs, such as advertising, office rent or labor not chargeable to production, are business expenses, not COGS. Under the uniform capitalization rules of section 263A, some producers and resellers must add part of their indirect costs to inventory.

Small Businesses That Do Not Have to Keep Inventories

A business that meets the gross receipts test of section 448(c) and is not a tax shelter does not have to keep inventories under the general rule: its method of accounting for inventory clearly reflects income if it treats inventory as non-incidental materials and supplies, or follows its applicable financial statement or, without one, its books and records (26 U.S.C. § 471(c)). The test looks at average annual gross receipts for the 3 prior tax years; the $25,000,000 in the statute is adjusted for inflation each year (§ 448(c)(1), (4)).

Tax years beginning inAverage annual gross receipts of the 3 prior yearsSource
2025$31,000,000 or lessPub. 334 (2025 returns)
2026$32,000,000 or lessRev. Proc. 2025-32, section 3.30
2027$33,000,000 or lessRev. Proc. 2026-35, section 3.32

If you choose to keep an inventory anyway, Pub. 334 says you must generally use an accrual method for purchases and sales and value the inventory each year to figure COGS in Part III of Schedule C. A corporation or partnership that uses one of the small business methods checks the box on Form 1125-A line 9a(iv), (v) or (vi). Changing the method needs Form 3115.

FIFO, LIFO and Average Cost: One Example, Three Answers

LotUnitsCost per unitLot cost
1 (beginning inventory)100$10.00$1,000.00
2 (first purchase)200$11.00$2,200.00
3 (second purchase)150$12.00$1,800.00
Available for sale450$5,000.00

The business sells 300 units. FIFO (first in, first out) assumes the oldest units sold first: 100 × $10 + 200 × $11 = $3,200 COGS, leaving $1,800 of inventory. LIFO (last in, first out) assumes the newest units sold first: 150 × $12 + 150 × $11 = $3,450 COGS, leaving $1,550. Average cost prices every unit at $5,000 ÷ 450 = $11.11: 300 units cost $3,333.33, leaving $1,666.67 (all computed, and reproduced by the calculator).

IRS Publication 538 defines FIFO and LIFO the same way, says specific identification is used when actual costs can be matched to items, and notes that in times of rising prices LIFO produces a larger cost of goods sold and a lower closing inventory, and FIFO the opposite. LIFO is adopted by filing Form 970, or a statement with the same information, with the timely filed return for the first LIFO year (Pub. 538), and LIFO is allowed only if the business used no other inventory method for that year in reports to shareholders, partners or other owners or for credit purposes (26 U.S.C. § 472(c)); tax LIFO keeps layers year by year, which this one-period example does not show. The average cost above is one weighted average for the whole period; a rolling (moving) average is recomputed after each purchase and can give a different result. For a rolling average, the IRS announced in Rev. Proc. 2008-43 that it generally views a rolling-average method used for financial accounting as clearly reflecting income, with two safe harbors, but not necessarily when inventory is held for several years or costs fluctuate substantially (IRB 2008-30).

Gross Margin From COGS

Gross profit is net sales minus COGS, and gross margin is gross profit divided by net sales. In the Pub. 334 example, $385,060 − $288,140 = $96,920 of gross profit, 25.17% of sales, so COGS is 74.83% of sales (computed). The same COGS divided by average inventory gives inventory turnover. Use the margin calculator to price for a target margin, the markup calculator to price from cost, and the inventory turnover calculator to see how fast the inventory sells.

How to Use the Calculator and the Excel Workbook

In the first mode, enter the four Schedule C amounts (lines 35, 36, 37 to 39 together, and 41) and, if you want the margin, net sales. In the second, enter units sold and each purchase lot in the order you bought it, starting with the beginning inventory; the calculator stops if you sell more units than you had. The workbook (Excel and PDF, US Letter) has a Schedule C sheet and a FIFO, LIFO and average cost sheet; every total is a formula over the yellow input cells.

Common mistakes

  • Counting all purchases of the year as COGS and forgetting the change in inventory.
  • Using list prices instead of the prices actually paid after trade discounts.
  • Leaving freight-in out of the cost of purchases.
  • Putting advertising, office rent or the owner's own pay into COGS.
  • Switching between FIFO and average cost from year to year without filing Form 3115.

Inventory Valuation in Draivix

Draivix Inventory Valuation & Accounting values stock at weighted average (the default) or FIFO by a valuation policy per warehouse, product or category, and turns every receipt, issue, transfer, adjustment and reversal into an accounting record. Freight and customs duties can be allocated across receipt lines as landed costs, and the inventory close compares movement values with the inventory account in the general ledger before a person approves it. Draivix does not offer LIFO and does not prepare tax returns.

Last reviewed: November 23, 2026, against IRS Publications 334 and 538, Form 1125-A, 26 U.S.C. §§ 448, 471 and 472, and Rev. Procs. 2025-32, 2026-35 and 2008-43. Examples are computed. This page is general information, not tax advice.

02Frequently Asked Questions

How do you calculate cost of goods sold?

Beginning inventory + purchases + labor, materials and other production costs − ending inventory. In the IRS Pub. 334 example: $37,845 + $283,250 − $32,955 = $288,140.

What is included in cost of goods sold?

Merchandise or raw materials at the price you pay, freight-in, direct and indirect manufacturing labor, materials and supplies used in production, containers that are part of the product and manufacturing overhead. Selling and office costs are not included.

What is the COGS formula with sales?

Gross profit = net sales − COGS, and gross margin = gross profit ÷ net sales. COGS as a percentage of sales is COGS ÷ net sales: $288,140 ÷ $385,060 = 74.83%.

Do small businesses have to keep inventory for taxes?

Not if they meet the § 448(c) gross receipts test and are not tax shelters: average gross receipts of $32 million or less for tax years beginning in 2026 and $33 million for 2027. They may treat inventory as non-incidental materials and supplies or follow their financial statements or books (26 U.S.C. § 471(c)).

What is the difference between FIFO and LIFO?

FIFO assumes the oldest units are sold first, LIFO the newest. When prices rise, LIFO gives a higher COGS and lower ending inventory. LIFO must be adopted on Form 970.

How do I calculate COGS with average cost?

Divide the total cost of goods available by the units available and multiply by the units sold: $5,000 ÷ 450 units × 300 units = $3,333.33.

Let’s start together

Tell us how your business works.

We will show you what a system that takes over part of that work could look like.

Book a consultation