Lelifi·tools

Cost of Goods Sold Calculator

Cost of goods sold adds everything you spent to get products ready to sell, then subtracts what you still own at year end. A shop with 165,000 dollars of goods available and 45,000 dollars left at year end sold 120,000 dollars of goods.

Add up what your goods cost you during the year, subtract what you still hold, and see the gross margin those sales left behind.

By the Lelifi editors ·

Key takeaways

Cost of goods sold in one lineCOGS = goods available for sale - ending inventoryRetail example: 165,000 - 45,000 = 120,000 dollarsMaker example: 64,000 - 10,000 = 54,000 dollarsGoods available = opening stock + buys + freight-in + labor + other costsClosing stock is money you already spent but have not sold yet.
Both worked examples reduce to one subtraction once the available cost is totaled.
Where each dollar of the 200,000 dollars in sales goesCOGS 120,000Gross profit 80,00040,000 + 120,000 + 5,000 = 165,000 dollars available for sale165,000 - 45,000 = 120,000 dollars of cost of goods soldGross margin 80,000 / 200,000 x 100 = 40 percent
The shop's 200,000 dollars of sales split into product cost and the margin that pays for everything else.
On this page
  1. What cost of goods sold covers
  2. The formula, line by line
  3. Worked example: a retail shop
  4. A maker, and one product at a time
  5. COGS is not every cost
  6. Valuing the inventory
  7. What to do with the number
  8. Mistakes that skew the result

What cost of goods sold covers

Cost of goods sold, usually written COGS, is what the products you sold this year cost you to buy or make. Sell a wrench, and the COGS is what you paid the wholesaler plus the freight to get it to your shelf. Sell a cabinet you built, and the COGS is the lumber, the screws, the finish and the shop labor that went into it. Money spent on rent, ads, insurance and your own pay lives somewhere else on the return.

IRS Publication 334 (2025), chapter 6 applies the idea to anyone who makes, buys or sells goods to produce income, and it leaves out personal service businesses such as doctor, lawyer and painter practices. The Census Bureau uses the same split in its retail data: its Annual Retail Trade Survey glossary defines gross margin as total sales less cost of goods sold. The number does two jobs at once. On a tax return it reduces taxable income. On a profit and loss statement it tells you what a sales dollar has left to cover everything else.

The calculator below follows the Schedule C structure that a sole proprietor files with Form 1040. It is an estimating tool for planning, not tax advice; your bookkeeping software or accountant works from your actual records.

The formula, line by line

The whole thing rests on one idea: the goods you had to sell this year either left the building or did not.

COGS = beginning inventory + purchases + freight-in + direct labor + materials and supplies + other direct costs - ending inventory

Everything you added to stock during the year joins whatever was on the shelf on January 1. Whatever is still on the shelf on December 31 comes back out, because you have not sold it yet. The IRS instructions for Schedule C (2025) line the steps up like this:

Schedule C lineWhat goes there
35. Inventory at beginning of yearYour opening stock at cost
36. PurchasesMerchandise bought for resale, net of returns and personal withdrawals
37. Cost of laborDirect and indirect factory labor; not amounts paid to yourself
38. Materials and suppliesHardware, chemicals and parts used in production
39. Other costsFreight-in, containers, and overhead allocated to production
40. Add lines 35 through 39Cost of goods available for sale
41. Inventory at end of yearYour closing stock at cost
42. Cost of goods soldLine 40 minus line 41

A few details from Publication 334 matter in practice. Purchases on line 36 are net of returns and allowances, and net of anything you took home for personal use. Trade discounts come off: you use the price you paid, not the sticker. Freight to bring goods in belongs on line 39 with other costs, while the freight you pay to send orders out is a selling expense, not COGS. And the ending inventory you subtract becomes next year's beginning inventory, so a counting error this year repeats itself next year with the opposite sign.

Worked example: a retail shop

Take a hardware store that starts the year with 40,000 dollars of stock on the shelves. During the year it buys 120,000 dollars of merchandise and pays 5,000 dollars of freight on those inbound deliveries. At the end of the year the shelves hold 45,000 dollars of goods. Sales for the year came to 200,000 dollars.

LineAmount
Beginning inventory40,000 dollars
Purchases120,000 dollars
Freight-in5,000 dollars
Goods available for sale40,000 + 120,000 + 5,000 = 165,000 dollars
Ending inventory45,000 dollars
Cost of goods sold165,000 - 45,000 = 120,000 dollars
Sales200,000 dollars
Gross profit200,000 - 120,000 = 80,000 dollars
Gross margin80,000 / 200,000 x 100 = 40 percent

Of every sales dollar, 60 cents went back out the door as product cost and 40 cents stayed to pay rent, utilities, payroll and, if things go well, the owner. Those 40 cents are the working margin for the whole business; a bad month on rent shows up against it, not inside COGS.

A maker, and one product at a time

A manufacturer carries more lines. Say a small shop starts the year with 12,000 dollars of work in progress and finished goods, buys 30,000 dollars of raw material, pays 1,500 dollars of inbound freight, 18,000 dollars of direct labor and 2,500 dollars of other production costs, and ends the year with 10,000 dollars on hand. Sales were 96,000 dollars.

LineAmount
Beginning inventory12,000 dollars
Purchases30,000 dollars
Freight-in1,500 dollars
Direct labor18,000 dollars
Other costs2,500 dollars
Goods available for sale12,000 + 30,000 + 1,500 + 18,000 + 2,500 = 64,000 dollars
Ending inventory10,000 dollars
Cost of goods sold64,000 - 10,000 = 54,000 dollars
Sales96,000 dollars
Gross profit96,000 - 54,000 = 42,000 dollars
Gross margin42,000 / 96,000 x 100 = 43.75 percent

You can also run the same logic on one product. A candle maker spends 4.20 dollars on wax and fragrance, 0.60 dollars on the jar and lid, 1.10 dollars of pour labor and 0.85 dollars of allocated overhead on each unit, so one candle costs 4.20 + 0.60 + 1.10 + 0.85 = 6.75 dollars to make. Making 1,000 candles puts 1,000 x 6.75 = 6,750 dollars into inventory. Sell 900 of them at 12.50 dollars and COGS is 900 x 6.75 = 6,075 dollars, the 100 candles left over are 100 x 6.75 = 675 dollars of ending inventory, and 6,075 + 675 = 6,750 ties out to the penny. Gross profit on the candles is 900 x 12.50 - 6,075 = 5,175 dollars, a margin of 5,175 / 11,250 x 100 = 46 percent.

COGS is not every cost

The line between product cost and operating expense decides whether a number lands in COGS or below it. Most calls are easy once you ask whether the cost exists only because goods were bought, made or moved in:

CostWhere it belongs
Freight to bring goods inCOGS
Freight to ship orders to customersOperating expense
Packaging that travels with the productCOGS
Production overhead for a manufacturerCOGS
Rent, utilities, insuranceOperating expense
Advertising and marketingOperating expense
Owner pay or drawOperating expense, never COGS
Sales tax collected from customersNeither, it is not income

Two confusions cause most of the trouble. The first is freight: inbound freight is part of getting the product ready to sell, outbound freight is part of making the sale. The second is your own pay. Publication 334 is plain that line 37 does not include amounts paid to yourself; an owner's draw is never COGS.

Valuing the inventory

Every figure above assumes you can put a dollar value on the stock. IRS Publication 538 (January 2022) describes the methods small businesses use. The cost method values goods at what you paid for them. The lower of cost or market method lets you write stock down when it is worth less than you paid. Retailers that mark goods up by a consistent percentage can use the retail method, valuing inventory at selling price and backing the margin out; Publication 538 walks through that arithmetic line by line.

Whatever method you pick, you stay with it. Changing the way you figure inventory cost requires IRS approval on Form 3115, because a switch can move income between years. Businesses that use LIFO, last in first out, file Form 970 in the first year they adopt it and keep using it on their returns for as long as they use it on their books.

What to do with the number

COGS on its own is an input to three numbers worth watching.

Gross margin is gross profit divided by sales. The SBA's glossary of business financial terms defines the gross profit margin as GP divided by net sales: the share of each sales dollar left after paying for the product. Markup divides the same gross profit by COGS instead, so one business describes itself two ways. A 40 percent margin is a 0.40 / 0.60 x 100 = 66.7 percent markup.

Inventory turnover divides COGS by average inventory, which is beginning plus ending divided by two. The hardware shop turns 120,000 / 42,500 = 2.82 times a year, which is 365 / 2.8235 = 129.3 days of stock on hand. A faster turn ties up less cash; a slower turn means money sitting on shelves.

How good any of those numbers are depends on the trade. The Census Bureau publishes gross margin as a percent of sales by kind of business in its Annual Retail Trade Survey, so compare your margin against shops that sell what you sell, not against a restaurant or a factory.

Mistakes that skew the result

Five habits move the number without anyone noticing.

Counting purchases at sticker price instead of at what you paid after discounts and returns inflates COGS. Forgetting inbound freight deflates it. Taking merchandise home without recording the withdrawal deflates purchases; Publication 334 says to credit those goods out at cost. Skipping the year end physical count is the largest single error, because shrinkage, breakage and theft only enter the books when someone counts the shelves. And mixing periods, say valuing beginning inventory from a fiscal year and ending inventory from the calendar year, makes the difference meaningless.

Service businesses get a pass on most of this. A consultant with no goods to sell leaves Part III of Schedule C empty. Materials that pass through to a job, like lumber for a carpenter, can still be tracked as supplies, but the calculator here is built for businesses that hold inventory.

Frequently asked questions

What is cost of goods sold?

The direct cost of the products you sold in a period: what you paid for merchandise, plus inbound freight, and for makers the labor and materials that went into the goods. Rent, advertising and your own pay are not COGS.

How do I calculate COGS for a small shop?

Add beginning inventory, purchases, freight-in and any direct costs, then subtract ending inventory. A shop with 40,000 + 120,000 + 5,000 = 165,000 dollars of goods available and 45,000 dollars left at year end has COGS of 120,000 dollars.

Does shipping count in COGS?

Freight you pay to bring goods in does; Publication 334 (2025) puts it on line 39 of Schedule C. Freight to ship orders to customers is a selling expense instead.

Is my own salary part of COGS?

No. Publication 334 states that cost of labor on line 37 does not include amounts paid to yourself. Owner pay and draws are never part of COGS.

What is the difference between COGS and operating expenses?

COGS rises and falls with sales volume, while operating expenses like rent and insurance do not. Gross profit is sales minus COGS, and net profit is what remains after operating expenses on top of that.

Do I have to count inventory every year?

Businesses that sell goods generally do. A small business taxpayer, one with average annual gross receipts of 31 million dollars or less for tax years beginning in 2025 per IRS Rev. Proc. 2024-40, can choose not to keep an inventory and instead treat the goods as nonincidental materials or supplies.

What inventory valuation methods does the IRS allow?

Cost, lower of cost or market, and the retail method, per Publication 538. LIFO is allowed for tax but requires Form 970 in the first year you adopt it.

Is COGS the same as purchases?

No. Purchases are one input. The shop above added 125,000 dollars of goods including freight and still sold only 120,000 dollars, because inventory grew by 5,000 dollars over the year.

How do I turn a gross margin into a markup?

Divide the margin by whatever is left of the sales dollar. A 40 percent margin is 0.40 / 0.60 x 100 = 66.7 percent markup on cost.

What is a good gross margin?

It depends on the trade. Grocery runs thin and jewelry runs wide. The Census Bureau publishes gross margin as a percent of sales by kind of business in its Annual Retail Trade Survey, so compare against your own line of business.

What if I took inventory home for personal use?

Remove the cost of those items from purchases before you total the year, as Publication 334 directs. The calculator has no separate line for it, so subtract it from your purchases figure yourself.

Can a service business use COGS?

Usually there is nothing to put there. A business that sells no goods leaves Schedule C Part III blank. Materials that go into customer jobs can be tracked as supplies instead.

How does COGS relate to inventory turnover?

Turnover is COGS divided by average inventory. The shop turns 120,000 / 42,500 = 2.82 times a year, which works out to 365 / 2.8235 = 129.3 days of stock on hand.

Spotted a wrong number or a broken result?

More Ecommerce tools

See all Ecommerce tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.