ForHosting KIT · Finance & money

Margin calculator

Revenue of 100,000 with 60,000 in cost of goods sold leaves 40,000 of gross profit, a 40% margin: 40 cents of every sales dollar. Check a product, a store or a whole income statement before overhead. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Revenue
100,000
Cost of goods sold
60,000
You get
Gross profit
40,000
Margin percent
40

The profit margin percentage — searched as a margin calculator, gross margin calculator, or profit margin from revenue and cost of goods sold — is the share of sales left after the cost of goods sold is subtracted. Given revenue and cost of goods sold in the same currency and for the same reporting period, the identity is revenue minus cost of goods sold, divided by revenue, expressed as a percentage. Founders, controllers, merchandisers, and analysts use this figure whenever they judge whether a product line, a store, or a whole income statement is keeping enough of each sales dollar after the goods themselves are paid for. This margin calculator accepts those two amounts, rejects a zero or negative revenue base instead of dividing by zero, and returns the margin percentage together with the restated formula.

What a profit margin means and how the formula works

A profit margin percentage answers one income-statement question: what share of revenue remains after the cost of goods sold is taken out? Searchers who type margin calculator, gross margin calculator, or profit margin from revenue and COGS want that quotient as a percentage, not a markup on unit cost, not an operating margin that also folds overhead, and not a net margin that also subtracts interest and tax.

Revenue is the denominator: the sales figure for the same period and the same entity as the cost of goods sold, typically net of returns and allowances, not cash collected and not bookings that have not yet been recognized. Cost of goods sold is the matched inventory, materials, and direct production cost of those sales, in the same currency. The identity is margin percent equals revenue minus cost of goods sold, divided by revenue, then multiplied by one hundred so the result is a percent.

A result of forty means forty cents of every sales dollar is gross profit. A result of zero means cost of goods sold equalled revenue. The calculator does not fetch a ledger, does not allocate overhead, and does not annualize a stub month unless you already put comparable amounts in both inputs.

Prefer the same currency and the same reporting period for both inputs; mixing last year's sales with this year's cost of goods sold is not a profit margin, it is a mixed snapshot that will mislead a reviewer.

Where a margin calculator earns its keep

Controllers and merchandisers use a profit margin calculator when a SKU, a store, or a whole P and L pack needs a comparable gross-margin figure before overhead is allocated. Pricing teams recompute the ratio from revenue and cost of goods sold so the catalogue card matches the management report, including the case of a period whose revenue is still zero and must fail rather than print Infinity.

Educators and accounting homework need an oracle that subtracts cost of goods sold from revenue, divides by revenue, multiplies by one hundred, and rejects a zero or negative denominator the way a marking scheme does, instead of letting a spreadsheet leak Infinity into a gradebook. Failed validation is not billed. Keep revenue positive, pin the rounded percent in tests, and you get reproducible margin figures for spreadsheets, workflow tools, and edge workers without standing up an accounting library of your own.

Use this capability when you already have both revenue and cost of goods sold; if you have only a unit cost and a desired markup, that is a different identity. Retail buyers and marketplace sellers can run the same identity on a product line or a channel once those two amounts are in hand, without mixing cash collections with recognized sales or folding operating overhead into the cost of goods sold line.

Income-statement packs

Convert revenue and cost of goods sold into a percent profit margin so a SKU, store, or P and L pack reports gross profit against sales, not against a markup on unit cost.

Pricing and catalogue cards

Reproduce the published margin from the sales line and the cost-of-goods-sold series, including rejection when revenue has not yet accrued.

Classroom and accounting homework

Mark profit-margin items with a deterministic oracle that subtracts cost of goods sold from revenue, returns a percent, and fails loudly on a zero or negative denominator.

Does this include operating overhead or produce an operating margin?

No. The identity is revenue minus cost of goods sold, over revenue. Overhead, interest, and tax belong in operating or net margin, which are different figures.

What is the difference between margin and markup?

Margin divides the gross profit by revenue, while a markup is measured on cost, so the two percentages differ for the same sale. This calculator returns the margin, the share of revenue you keep.

Can a profit margin be negative?

Yes. If the cost of goods sold is larger than revenue, the goods cost more than they sold for and the margin comes out below zero. That is a valid result, not an error.

What if the cost of goods sold is zero?

Then the whole of revenue is gross profit and the margin is 100%. Revenue, on the other hand, must be above zero, because a margin cannot be measured on no sales.

Can I work out the margin on a single item?

Yes. Enter the unit selling price as revenue and the unit cost as cost of goods sold. The result is the margin on that one item rather than on a whole period.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/fin/margin

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/fin/margin \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"revenue":100000,"cost_of_goods_sold":60000}'
{
  "revenue": 100000,
  "cost_of_goods_sold": 60000
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "fin.margin",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

What a profit margin means and how the formula works

A result below zero means the goods cost more than they sold for, which is a valid arithmetic result and not a rejected input. Revenue must be strictly greater than zero because a zero or negative sales base makes the margin undefined; this endpoint fails with invalid_input instead of printing Infinity.

Input contract, response shape, rounding, and error behaviour

Example: revenue of two hundred fifty against cost of goods sold of one hundred seventy-five yields thirty. A new venture whose sales have not yet started must fail rather than print Infinity. Do not send a unit selling price in place of revenue unless you are deliberately computing a unit-level margin with unit cost in the cost-of-goods-sold field. Keep both figures on the same gross-or-net basis so the percent you store next to an income statement is the same percent a reviewer can recompute from the two lines you already published. POST a JSON body with two required finite numbers: revenue and cost_of_goods_sold, in the same currency, covering the same reporting period. revenue (aliases sales, sales_revenue, net_sales, and net_revenue) must be a finite number strictly greater than zero because the profit margin divides by revenue. cost_of_goods_sold (aliases cogs, cost_of_sales, and cost) must be a finite number; zero is allowed and yields a one-hundred percent margin, and a figure larger than revenue is allowed and yields a negative margin when the goods cost more than they sold for. Missing fields, empty strings, non-finite values, and a zero or negative revenue base fail with invalid_input naming the issue, and those failures are not billed. On success the body echoes both inputs, returns gross_profit as revenue minus cost of goods sold, margin_percent as the percent quotient rounded to twelve decimal places, and a formula string restating the identity. Example: revenue of one hundred thousand against cost of goods sold of sixty thousand yields margin_percent 40. Pair the percent with your own notes if the memo needs a target flag; this endpoint computes the profit margin only and does not invent an operating margin, a contribution margin, or a markup on cost.

How is profit margin calculated from revenue and cost of goods sold?

Send finite numbers revenue (> 0) and cost_of_goods_sold in the same currency. The API returns margin_percent = (revenue − cost_of_goods_sold) / revenue × 100 as a percentage.

What happens if revenue is zero or negative?

The task fails with invalid_input. A profit margin cannot divide by a zero or negative revenue base, so the request is rejected and is not billed.

Is the result a percent or a decimal?

The primary field margin_percent is a percentage (40 for a 40% margin), which is revenue minus cost of goods sold, divided by revenue, multiplied by one hundred.

What does the margin calculator cost?

The browser tool is free. API requests use prepaid balance at $0.002 per successful call; invalid input is not billed.

Read the full KIT documentation →