Skip to content
FinToolSuite
Updated May 8, 2026 · Digital Nomad & Freelance · Educational use only ·

Cost of Goods Sold Calculator

COGS, gross profit, and gross margin from beginning inventory, purchases, and ending inventory.

Calculate cost of goods sold from beginning inventory, purchases, and ending inventory. Returns COGS, gross profit, and gross margin when revenue is entered.

What this tool does

This calculator computes cost of goods sold using the standard inventory-flow formula: beginning inventory plus purchases minus ending inventory. The result represents the total cost attributed to goods that left your inventory during the period. When you enter revenue, the tool also calculates gross profit (revenue minus COGS) and gross margin (gross profit divided by revenue), expressed as a percentage. The accuracy of your COGS output depends most on the reliability of your beginning inventory, purchases, and ending inventory figures. This tool is useful for closing accounting periods on a product business, reconciling inventory records, or checking COGS calculations derived from other sources. Note that this calculator models the accounting treatment of inventory flows and does not account for write-downs, returns adjustments, or non-inventory costs like labour or overhead.


Enter Values

People also use

Formula Used
Beginning inventory value
Purchases during the period
Ending inventory value
Period revenue (optional input)
Cost of goods sold

Spotted something off?

Calculations or display — let us know.

Disclaimer

Results are estimates for educational purposes only. They do not constitute financial advice. Consult a qualified professional before making financial decisions.

What this calculator does

Cost of goods sold is the direct cost of inventory that left the business during a reporting period — what was sold, valued at what it cost to produce or acquire. It sits above gross profit on an income statement and is the largest single expense line in most product businesses. The figure is computed from inventory flow rather than direct measurement: whatever opening inventory plus purchases produced, minus whatever's still on the shelf at period end, is the cost of what was sold. The calculator returns COGS as the headline figure and adds gross profit and gross margin when revenue is supplied so the figure sits in context.

How the math works

The formula is the inventory identity: COGS = BI + P − EI, where BI is beginning inventory, P is purchases during the period, and EI is ending inventory. Gross profit is revenue minus COGS; gross margin is gross profit divided by revenue. The identity assumes inventory counts at period start and period end are accurate — a miscount in either direction flows directly into COGS and from there into every downstream margin figure. Accurate counts at both endpoints are essential for the figure to mean what it claims to mean. For service businesses without physical inventory, an equivalent cost-of-revenue line is computed differently — typically from direct delivery costs incurred in the period — but the role of the figure in the income statement is the same.

Worked example

A product business with 50,000 in beginning inventory, 120,000 in purchases during the period, and 40,000 in ending inventory. COGS: 50,000 + 120,000 − 40,000 = 130,000. With 200,000 in revenue across the same period, gross profit is 200,000 − 130,000 = 70,000, and gross margin is 70,000 ÷ 200,000 = 35%. The 35% margin tells the operator that for every unit of revenue, 35 units are available to cover all the costs that sit below the gross profit line — operating expenses, taxes, financing, and what's left as net profit. A miscount at either inventory endpoint would distort all four figures simultaneously.

Why gross margin sits at the top of analysis

Gross margin is the upper bound on net margin: every other expense competes for what gross profit leaves behind. A business cannot produce a healthy net margin from a weak gross margin no matter how disciplined operating expenses are, because the gross figure caps the available room. Operators tracking margin trends month-on-month catch deteriorations earlier than those tracking net margin alone — gross margin moves first, and net margin follows once cost discipline can no longer absorb the change. The calculator's role is to surface the figure quickly enough to track it as a routine close-of-period check rather than as an annual review.

What counts as COGS and what does not

The boundary varies by business model, and the consequences for reported gross margin are real. Direct material costs, direct labour for production, and inbound freight to bring inventory to the warehouse are typically COGS. Packaging that ships with the product is typically COGS. Inbound storage during production flow is sometimes COGS, sometimes operating expense, depending on whether it sits within the inventory cycle or supports overhead more broadly. Marketing, sales commissions, customer support, software tools that are not used in production, and salaries of people not directly producing the product are typically operating expenses. The classification matters because it determines whether the cost compresses gross margin (COGS) or operating margin (OpEx) — the same total spend produces different headline figures depending on where it lands.

COGS in service businesses

Service businesses report a cost-of-revenue line that plays the same role as COGS without the inventory-flow identity. For a consultancy, that figure is typically the pass-through cost of contractors delivering client work plus client-specific tools and travel. For a SaaS business, it is hosting, third-party APIs, and the customer-success cost that scales with customer count. For a creative studio, it is freelancer fees and licensed assets used on client deliverables. The label and the inputs change but the position in the income statement and the role in margin analysis stay the same. Service businesses entering a cost-of-revenue figure in the calculator can use the BI and EI inputs at zero and enter the period's direct delivery cost in the purchases field.

Common errors to avoid

Three errors recur across small and growing operations. Inventory in transit at period end is sometimes double-counted — it appears on a purchase order but has not arrived, so it should not be in ending inventory but sometimes ends up there because it's expected. Inbound freight is sometimes expensed instead of capitalised into inventory; under either treatment the figure is real, but landed-cost treatment is the standard convention and produces a more accurate per-unit cost. Outbound fulfillment costs (picking, packing, shipping to the customer) sometimes get classified into COGS when they more naturally belong in operating expenses; the classification is allowed either way under most standards but typically applied consistently across periods so that gross margin is comparable period-on-period.

Example Scenario

COGS of 130,000.00 = $50,000 beginning + $120,000 purchases − $40,000 ending inventory.

Inputs

Beginning Inventory:$50,000
Purchases During Period:$120,000
Ending Inventory:$40,000
Revenue (optional):$200,000
Expected Result130,000.00

This example uses typical values for illustration. Adjust the inputs above to match a specific situation and see how the result changes.

Sources & Methodology

Methodology

COGS = beginning inventory + purchases − ending inventory. Gross profit = revenue − COGS (when revenue is entered). Gross margin = gross profit ÷ revenue. The inventory-flow identity is standard under both IFRS and US-GAAP product accounting; service businesses report an equivalent cost-of-revenue line computed from direct delivery costs in the period rather than from inventory movement. The calculator does not enforce a specific cost-flow assumption (FIFO, LIFO, weighted-average) — the figures entered should reflect whichever convention the operator's books are kept on, applied the same way at both inventory endpoints. Outbound fulfillment, marketing, and overhead are typically classified outside COGS in operating expenses, though landed-cost or absorption treatments place some of those costs in inventory; the calculator works at whichever classification is entered.

Frequently Asked Questions

What is the difference between COGS and operating expenses?
COGS is the direct cost of goods that were sold in the period — materials, direct production labour, inbound freight under landed-cost treatment. Operating expenses are the indirect costs of running the business — rent, marketing, software, salaries of people not directly producing the product. COGS sits above gross profit on the income statement; operating expenses sit between gross profit and operating profit. Two businesses with the same total spend can report very different gross margins depending on where each line lands, which is why the classification convention applied at both inventory endpoints needs to be the same.
Should shipping costs be in COGS?
Inbound shipping (getting product to the warehouse) is typically capitalised into inventory and flows through COGS as the inventory is sold — it's part of the landed cost of the goods. Outbound shipping (getting product to the customer) is typically classified as an operating expense, though landed-cost or absorption treatments sometimes move it into COGS. Both treatments are allowed under standard accounting conventions; the choice affects gross margin without affecting net margin, and is normally applied consistently across periods so that period-on-period gross margin movement is interpretable.
How is the figure computed for a business without physical inventory?
Service businesses use a cost-of-revenue line that plays the same role as COGS but is computed differently. Instead of the inventory-flow identity, the figure is the direct cost incurred to deliver revenue in the period — contractor pass-through fees, hosting and infrastructure for SaaS, freelancer fees on client work for studios. Setting beginning inventory and ending inventory to zero in the calculator and entering the period's direct delivery cost in the purchases field produces the equivalent cost-of-revenue figure. The methodology section explains the framing in more detail.
Can COGS be negative?
The arithmetic allows it when ending inventory exceeds beginning plus purchases, but a negative COGS in a well-maintained set of books is usually a sign of a miscount or a misclassified entry rather than a genuine economic figure. Possible causes include double-counting in-transit inventory at period end, classifying an expense as inventory when it should have been an operating expense, or carrying goods in beginning inventory that no longer exist. The calculator displays a negative figure when the inputs produce one rather than refusing to run, but the result should be reviewed against actual inventory movements before being used.
Why do figures sometimes differ from accounting-software COGS?
Several reasons. Cost-flow assumptions (FIFO, LIFO, weighted-average) produce different per-unit costs and so different period COGS even when total inventory matches. Landed-cost treatment of freight versus expensing in-period changes which line carries the freight. Inventory write-downs for damaged or obsolete stock sometimes hit COGS and sometimes a separate write-down line. Period-end cut-off conventions for in-transit inventory differ across systems. The calculator works at whichever inputs reflect the operator's own books; it does not impose a specific convention but does require the same convention applied at both inventory endpoints for the figure to be coherent.

Related Calculators

More Digital Nomad & Freelance Calculators

Explore Other Financial Tools