Cost of goods sold (COGS) is the single most important cost line for any business that sells physical products. It determines gross profit, drives gross margin, and feeds inventory turnover. This calculator computes COGS from the periodic-inventory formula, then chains it into margin and turnover so you can see the full picture from one set of inputs.

How COGS is calculated

The periodic formula is simple: Beginning Inventory + Purchases + Direct Costs − Ending Inventory. The logic is that everything available to sell, minus what is still on the shelf, equals what was sold. Beginning and ending inventory come from your balance sheet; purchases and direct costs come from the period's activity.

Direct costs are the part most people miss. Freight-in — the cost of getting inventory to you — is part of COGS, not a separate shipping expense. For manufacturers, direct labor and manufacturing overhead also belong in COGS. Anything required to make the product ready to sell is a direct cost; everything else (marketing, rent, admin) is an operating expense.

From COGS to gross profit and margin

Once you have COGS, gross profit is just revenue minus COGS, and gross margin is gross profit divided by revenue. Margin is the more useful figure because it normalizes for size: a corner store and a national chain can be compared on margin even though their dollar profits differ by orders of magnitude.

Watch the difference between margin and markup. Markup divides gross profit by cost; margin divides it by revenue. A product bought for $50 and sold for $100 has a 100% markup but a 50% margin. Pricing from markup while reporting on margin is a frequent source of confusion — the calculator displays both so you can keep them straight.

What counts as a 'good' margin depends on the industry. Grocery and distribution run thin (15–25%), general retail and manufacturing sit in the middle (30–45%), and software and premium services can exceed 70%. The verdict badge on the margin tab puts your number in that context.

Periodic vs. perpetual inventory, and what COGS leaves out

This calculator uses the periodic method: COGS is computed once per period from beginning inventory, purchases, and a physical ending count. The perpetual method updates inventory and COGS continuously after each sale through a point-of-sale or ERP system. Both produce the same annual COGS when counts are accurate; periodic is simpler for reporting, while perpetual gives real-time visibility.

Remember what COGS does not include: it covers only the direct cost of goods sold, never operating expenses. Gross profit minus operating expenses gives operating income — a separate line. If your ending inventory ever exceeds goods available for sale, the formula returns a negative COGS, which is impossible; the calculator flags this so you can recheck your figures. The cost-flow assumption you use for inventory (FIFO, LIFO, or weighted average) affects the dollar values you enter, but the formula itself is identical.