Skip to main content
Display

How to calculate cost of goods sold (COGS)

Cost of goods sold is what the products you sold cost you. It is the number that turns sales into gross profit, so getting it right matters for pricing, taxes and knowing whether you are actually making money.

Updated · 3 min read · By the YourAILedger team

The COGS formula

COGS = beginning inventory + purchases − ending inventory

Beginning inventory is the value of stock at the start of the period. Purchases are the costs of products you bought during the period, including the costs to get them ready to sell. Ending inventory is the value of stock you still hold at the end, usually from a count.

If you track inventory perpetually, your system records COGS with each sale instead. The formula is still useful as a check at the end of each period.

A worked example

LineAmount
Beginning inventory$12,000
+ Purchases from suppliers$30,000
+ Inbound freight and duties$1,500
− Ending inventory (from the count)$10,500
= Cost of goods sold$33,000

If sales for the same period were $55,000, gross profit is $55,000 − $33,000 = $22,000, and gross margin is $22,000 ÷ $55,000 = 40%. Try your own numbers in the profit margin calculator.

What to include, and what to leave out

Usually in COGSUsually not in COGS
Product cost, after supplier discounts and returnsShipping orders to customers (often a selling expense)
Inbound freight to your warehouseAdvertising and marketing
Import duties and customs brokerageOffice rent and utilities
For makers: raw materials, direct labor and production overheadOwner and office salaries

Whatever you decide for borderline costs, such as packaging or outbound shipping, apply it the same way every period. Consistency matters more than any single choice.

Why COGS matters

  • Pricing. If you do not know what a product really costs, you cannot price it for a target margin.
  • Inventory health. Inventory turnover is COGS divided by average inventory. Low turnover means cash tied up in slow stock. See the inventory turnover calculator.
  • Taxes. COGS reduces taxable income. In the US, sole proprietors report it in Part III of Schedule C, and partnerships and corporations generally use Form 1125-A.

Common COGS mistakes

  • Using purchases as COGS without adjusting for the change in inventory.
  • Leaving freight and duties out of product cost.
  • Guessing ending inventory instead of counting.
  • Changing what counts as COGS from one month to the next.

How you value ending inventory also changes COGS when your purchase prices change. See FIFO vs weighted average cost for a side-by-side example.

Common questions

Is COGS the same as operating expenses?

No. COGS covers the products you sold. Operating expenses, such as rent, marketing and office salaries, are listed separately below gross profit.

Do service businesses have COGS?

Some do. A service business that buys materials or pays subcontractors for specific jobs may track those as cost of sales. Ask your accountant how to set this up for your business.

Keep your books this way without the busywork

YourAILedger tracks inventory, purchase orders and suppliers, reconciles imported bank statements and guides your month-end close. Plans start at $29 a month.

Start my 14-day free trial

No credit card required.

This guide is general education, not tax, legal or accounting advice. Rules vary by business and location, so confirm your situation with a qualified professional.