Cogsly

Your COGS, gross profit, and margin — in one calculation.

Cogsly is a free, client-side calculator for Cost of Goods Sold (COGS), gross profit, and gross margin. Enter your inventory figures, hit calculate, and get instant results. No sign-up and no server calls.

The COGS formula and what each variable means

COGS = Beginning Inventory + Purchases + Direct Expenses - Ending Inventory. Four inputs, one subtraction. You can verify it on a single line of a spreadsheet, and you should, because every accounting platform we've touched quietly re-aggregates at least one of those four numbers and labels the result something different.

COGS = Beginning Inventory + Purchases + Direct Expenses - Ending Inventory

Beginning Inventory is the dollar value of unsold stock on day one, pulled from the prior balance sheet. Purchases is everything you bought or manufactured during the period, at landed cost. Direct Expenses is the slippery one, and it gets the next section to itself. Ending Inventory is the recount on the final day.

Two derived metrics fall out once you have revenue:

Gross Profit = Revenue - COGS
Gross Margin = (Gross Profit / Revenue) x 100%

What counts as a direct expense (and what does not)

A direct expense is any cost you can trace to a specific unit or batch. Freight-in is the obvious one. Import duties paid on the way in, packaging applied per unit, factory labor allocated against specific production runs, and subcontracted manufacturing all live here too.

Outbound shipping (the cost of getting goods from your warehouse to the customer) is not COGS. It's a selling expense and sits below the gross-profit line. We see this miscategorized constantly on Shopify exports because the platform reports inbound and outbound shipping in adjacent columns. They are not adjacent on an income statement.

Office rent, admin salaries, marketing spend, and software subscriptions stay out of COGS. The test is simple: can you tie this dollar to a SKU? If not, it's overhead.

A worked example: COGS, gross profit, and margin from real numbers

A small Etsy seller closes Q1 2026 with the following figures: Beginning Inventory (Jan 1) $12,400, Purchases (Q1) $28,750, Freight-in $1,820, Import duties $640, Packaging $310, Ending Inventory (Mar 31) $15,200, Revenue (Q1) $48,900.

Plugging the numbers into the formula:

Direct Expenses = $1,820 + $640 + $310                  = $2,770
COGS            = $12,400 + $28,750 + $2,770 - $15,200  = $28,720
Gross Profit    = $48,900 - $28,720                     = $20,180
Gross Margin    = ($20,180 / $48,900) x 100%            = 41.27%

41% is healthy for handmade goods on Etsy and thin for branded consumables on Amazon. Margin context is industry-specific. The formula isn't.

Assumptions baked into the formula

Three assumptions sit underneath every COGS number you'll ever calculate.

First, your cost-flow method. FIFO assigns the oldest costs to COGS first; in a period of rising prices, FIFO produces a lower COGS and a higher reported gross profit. LIFO does the opposite, is permitted under US GAAP, and is banned under IFRS. Weighted-average splits the difference. Cogsly is method-agnostic: it calculates from the values you give it, and those values carry the method.

Second, your physical count is accurate. Perpetual systems drift. We built Cogsly partly because we kept watching a client's Shopify perpetual count diverge from a quarterly physical count by 3 to 7 percent every cycle, which moved gross margin by enough to matter for pricing.

Third, period boundaries. A purchase order placed December 30 and received January 4 belongs in Q1's purchases, not Q4's. Cutoff errors are the most common source of COGS misstatements in founder spreadsheets, full stop.

When the formula breaks down

The equation assumes goods get sold or held. Write-offs (damaged, expired, or shrunk stock) produce no revenue. Standard practice is to fold them into COGS, which depresses margin honestly. Pulling write-offs into a separate operating expense to protect the gross-margin line is aggressive, and your auditor will notice.

Service revenue mixed with product revenue is the other failure mode. If 30% of your top line is installation or support contracts, only the product portion belongs against COGS. Otherwise your margin number is a blend of two businesses.

Manufacturers carrying work-in-process inventory need an expanded version that splits raw materials, WIP, and finished goods. The form at the top of this page is the merchandising version. For a factory, Cogsly will get you close; a real cost-accounting system gets you correct.

Frequently Asked Questions

How do I calculate cost of goods sold?

COGS = Beginning Inventory + Purchases + Direct Expenses - Ending Inventory. Enter your beginning inventory value, add any purchases and direct costs (like freight-in or import duties), then subtract the ending inventory value. The result is your cost of goods sold for that period.

What is the COGS formula?

The standard COGS formula is: Cost of Goods Sold = Beginning Inventory + Purchases + Direct Expenses - Ending Inventory. Once you know COGS, Gross Profit = Revenue - COGS, and Gross Margin = (Gross Profit / Revenue) x 100%.

How do I include freight in cost of goods sold?

Freight-in (inbound shipping to receive inventory) is a direct expense and should be included in COGS. Add it to the Direct Expenses field alongside import duties, factory labor, and packaging costs. Outbound shipping to customers is not part of COGS — it is an operating expense.

What counts as a direct expense vs overhead?

Direct expenses are costs tied to specific products: raw materials, freight-in, import duties, factory labor, packaging, and subcontracted manufacturing. Overhead costs like office rent, administrative salaries, marketing, and outbound shipping are not included in COGS.

How do I calculate gross profit margin from COGS?

First calculate Gross Profit = Revenue - COGS. Then Gross Margin = (Gross Profit / Revenue) x 100%. For example, if revenue is $100,000 and COGS is $60,000, gross profit is $40,000 and gross margin is 40%.

What is the difference between COGS and total expenses?

COGS includes only direct costs of producing or purchasing goods sold — inventory, materials, freight-in, and direct labor. Total expenses also include operating costs like rent, salaries, marketing, and depreciation. COGS is subtracted from revenue to get gross profit; total expenses are subtracted to get net profit.

Do I include shipping costs in COGS?

Only inbound shipping (freight-in) belongs in COGS — the cost of receiving inventory from suppliers. Outbound shipping (sending orders to customers) is an operating expense, not a cost of goods sold.

Your Data Stays in Your Browser

Cogsly runs entirely in your browser. Every calculation happens client-side using JavaScript. No inventory figures, revenue numbers, or financial data are ever transmitted to a server, stored in a database, or shared with third parties.

There are no user accounts, no cookies for tracking financial inputs, and no server-side processing. When you close or refresh the page, your numbers are gone.

For full details, see our Privacy Policy.