ForHosting KIT · Finance & money

Profit margin calculator

Enter a cost and a selling price to get profit, margin and markup side by side: a cost of 80 sold at 100 is a 20% margin but a 25% markup. Selling below cost shows the loss as a negative margin. 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
Cost
80
Price
100
You get
Profit
20
Profit margin (%)
20
Markup (%)
25

Computes profit, gross margin percentage, and markup percentage from a unit cost and a selling price, distinguishing the two ratios that are often confused.

Profit, margin and markup, and how they differ

From a cost and a price this tool returns three numbers. Profit is simply price - cost. Margin percent is (price - cost) / price * 100, expressing profit as a share of the selling price.

Markup percent is (price - cost) / cost * 100, expressing the same profit as a share of the cost. These two ratios are routinely confused: a cost of 80 sold at 100 yields a 20% margin but a 25% markup, and the tool returns both so you never mix them up. The output echoes the cost and price you supplied so a stored result is self-describing without needing the original request.

Fields, validation and edge cases

Two fields are required: cost, a finite number greater than or equal to 0, and price, a finite number greater than or equal to 0. A price below the cost is allowed and simply produces a negative profit and negative margin, which is the correct signal for a loss-making sale rather than an error. The optional decimals field is an integer from 0 to 8 and defaults to 2, giving finance workflows room for high-precision unit economics.

Price a product correctly

Enter your landed cost and target price to see the true margin, and avoid the classic mistake of quoting markup as if it were margin.

Model discounts and losses

Test a price below cost to see the negative profit and margin, quantifying exactly how deep a promotional discount cuts.

What is the difference between margin and markup?

Margin is profit as a percent of price; markup is the same profit as a percent of cost. Cost 80 at price 100 is a 20% margin but a 25% markup.

Why can't price be zero?

Price is the denominator of the margin percentage, so a zero price would divide by zero.

Can I model a loss?

Yes. A price below cost is allowed and returns a negative profit and negative margin, not an error.

How precise can the output be?

The decimals field accepts 0 to 8 (default 2), rounded half-up.

What happens when the cost is zero?

The margin is 100%, because the whole price is profit. The markup cannot be calculated, since it would mean dividing by zero, so it is left empty instead of showing a misleading number.

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/dev/profit-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/dev/profit-margin \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cost":80,"price":100}'
{
  "cost": 80,
  "price": 100
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev.profit_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.

Profit, margin and markup, and how they differ

When cost is 0 the markup is mathematically undefined (division by zero), so markup_percent is returned as null while margin_percent stays valid at 100.

Fields, validation and edge cases

There is one hard exception: price may not be 0, because it is the denominator of the margin, so a zero price returns the typed error "price no puede ser 0". Every input is checked for type, finiteness and range before any arithmetic, and a violation returns invalid_input naming the field, for example a negative cost or a non-numeric price.

Rounding, determinism and delivery

Rounding uses an explicit half-up rule on the exact IEEE result, applied independently to profit, margin_percent and markup_percent, so a value of 12.345 becomes 12.35 rather than drifting through a locale-dependent formatter. Failed API tasks are never charged; prepaid balance is spent only on successful work at $0.002.

Audit a catalogue in bulk

Send each SKU's cost and price through the API to flag items whose margin_percent falls below your threshold.

What if cost is zero?

Profit and margin are still valid, but markup is undefined (division by cost), so markup_percent is returned as null.

Read the full KIT documentation →