Margin-discount calculator
To keep a 25% margin on an item costing 60 while advertising 20% off, print 100 on the ticket: after the discount it sells for 80, and 20 of that is profit. Plan promotions without eroding your margin. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Cost
- 60
- Margin
- 25
- Discount
- 20
- Sale price
- 80
- Required price
- 100
- Profit
- 20
Retail teams often know the unit cost, the profit margin they must keep, and the percent-off they intend to advertise, and they still print the wrong ticket because they mark up cost and then take the discount off that inflated figure. The margin that finance will measure is profit as a share of the price the customer actually pays after the markdown, not as a share of cost, so a twenty percent advertised discount shrinks the denominator that the target margin lives on. This margin-discount calculator accepts a positive unit cost, a target profit margin percent, and a discount rate percent, then returns the list (ticket) price that, after the discount, still delivers that margin on cost.
How cost, target margin, and advertised discount set the ticket price
Merchants usually know three numbers before they print a ticket: what the unit costs, what profit margin they must keep after the promotion, and what percent off they intend to advertise. Those three numbers do not combine by adding a markup to cost and then knocking the discount off the inflated figure, because the markdown shrinks the sale price that the margin is measured against. Profit margin here is profit as a share of the post-discount selling price, not as a share of cost.
If the unit cost is C, the target margin is M percent, and the advertised discount is D percent, the sale price that still delivers that margin is C divided by one minus M over one hundred. The list or ticket price that must be shown before the discount is that sale price divided by one minus D over one hundred. Combined, the required list price is C divided by the product of those two remainders.
A cost of sixty with a twenty-five percent target margin and a twenty percent advertised discount therefore needs a sale price of eighty and a ticket of one hundred: after twenty percent off, eighty remains, and sixty of that eighty is cost, which is a twenty-five percent margin. A discount of one hundred percent or more leaves no remaining price, so the identity is undefined and the task fails. A target margin of one hundred percent or more would require an infinite sale price and is likewise rejected.
Zero discount is allowed and reduces to the classic selling-price-from-margin identity. Zero margin is allowed and prices the sale at cost, so the ticket is cost divided by one minus the discount fraction.
What you can do with it
Retail circulars that advertise a percent off
Merchandisers enter unit cost, a floor margin, and the advertised markdown, then lock the resulting list ticket so every SKU still clears the margin after the sale.
Wholesale list prices with a trade discount
Sales teams publish a list that, after the contracted trade discount, still delivers the agreed profit margin on supplier cost.
FAQ
How do I calculate a list price that preserves margin after a discount?
Sale price equals cost / (1 − margin/100). Required list price equals that sale price / (1 − discount/100). The response also includes profit on the post-discount sale.
Why not mark up cost and then take the discount off that figure?
Because profit margin is measured on the price the customer pays after the markdown. Taking a percent off a cost-plus ticket shrinks the denominator and under-delivers the margin you thought you had booked. This calculator solves the identity in the right order.
What happens if the discount is 100 percent or more?
A total markdown leaves no remaining sale price, so a finite ticket that preserves a margin cannot exist. Those failures are not billed.
Can the discount or the margin be zero?
Yes. Zero discount reduces to the classic selling-price-from-margin identity: required price equals cost / (1 − margin/100). Zero margin prices the sale at cost, so the ticket is cost divided by one minus the discount fraction. Negative values are rejected.
Is the target margin measured on cost or on the selling price?
On the price the customer actually pays after the discount, not on cost. In the example, a 25% margin on a sale price of 80 is a profit of 20, with the remaining 60 covering the cost.
Related tools
For developers — API access
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.
API endpoint
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.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/fin/margin-discount \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"cost":60,"margin":25,"discount":20}'const res = await fetch("https://api.kit.forhosting.com/fin/margin-discount", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"cost": 60,
"margin": 25,
"discount": 20
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/fin/margin-discount",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"cost": 60,
"margin": 25,
"discount": 20
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/fin/margin-discount", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"cost":60,"margin":25,"discount":20}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"cost":60,"margin":25,"discount":20}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/fin/margin-discount", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"cost": 60,
"margin": 25,
"discount": 20
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "fin.margin_discount",
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
A discount of one hundred percent or more leaves no remaining sale price and fails with invalid_input.
Input contract, response shape, and error behaviour
A target margin of one hundred percent or more fails for the same structural reason: the sale price would be infinite. Negative cost, negative margin, and negative discount are rejected. Money fields round half-up to two decimal places so goldens compare byte-for-byte across runtimes. POST a JSON body with three required finite numbers in one currency. cost is the unit acquisition or production amount and must be strictly greater than zero; aliases unit_cost, cost_price, and cogs map to the same field so a catalog importer can keep its column names. margin is the target profit margin as a percent of the post-discount selling price, from zero inclusive to one hundred exclusive; aliases margin_percent, target_margin, and profit_margin are accepted. discount is the advertised markdown as a percent of the list (ticket) price, also from zero inclusive to one hundred exclusive; aliases discount_percent, discount_rate, and percent_off are accepted. Each numeric field may arrive as a JSON number or a numeric string. Missing fields, empty strings, and non-finite values fail with invalid_input naming the field. Those failures are not billed. A discount of one hundred percent or more fails with invalid_input because no remaining sale price exists after a total markdown. On success the body echoes the normalized cost, margin, and discount, then reports sale_price (the post-discount price that hits the margin), required_price (the list ticket to print), profit as sale_price minus cost, and a formula string restating the two-step identity. Example: cost sixty, margin twenty-five, discount twenty yields sale_price eighty, required_price one hundred, and profit twenty. Pair this endpoint with a currency converter only if the three numbers already share one currency; the calculator does not convert FX, layer sales tax, or stack a second markdown. Pricing is a flat $0.002 per successful request.
Where a margin-discount calculator earns its keep
Promotional planners use a margin-discount calculator when they already promised a percent-off in a circular and still need every SKU to clear a floor margin after the sale. Category managers back into a ticket from supplier cost, a contract margin, and a house markdown rather than discovering on Monday that last week's twenty percent off quietly erased the contribution they had booked. Wholesale desks that advertise a trade discount on a published list price set that list so the net invoice still carries the agreed margin, instead of treating list as an independent vanity figure. Failed validation does not consume balance. Pricing bots and ERP connectors call a stable prepaid contract so catalog imports, rule engines, and chat assistants share one deterministic ticket instead of three slightly different spreadsheet identities. This is a different search and a different job from a discount calculator that starts from an already-known list price, from a selling-price-from-markup tool that never sees a promotion, and from a finance discount-rate calculator that prices present value against future value: those tools start from different inputs and answer different questions. Keep cost strictly positive, keep margin and discount below one hundred percent, pin the rounded required_price in tests, and you get a reproducible promotional ticket for shelf labels, LMS plugins, and edge workers without standing up a full pricing engine of your own.
Integration use cases
Pricing bots and ERP connectors
Automations call a stable prepaid endpoint so catalog imports and rule engines share one deterministic ticket that preserves margin after discount.
Technical questions
What does the margin-discount calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.