Margin Calculator
Calculate profit margin as a percentage of price from cost and price, refusing a zero price.
What this calculator does
Profit margin expresses the difference between price and cost as a percentage of the selling price.
The result is printed as the profit margin percentage.
How to use it
Enter the cost and the price, then press Run.
The inputs are:
- Cost (starts at 80)
- Price (starts at 100)
Worked example
Input: 80.00 cost and 100.00 price.
Output: Margin = 20.0000% (price 100.00, cost 80.00).
Assumptions and rounding
Cost and price are per unit in the same currency. Margin prints to four decimal places; a price below cost produces a negative margin rather than an error.
What it refuses
A zero or negative price is refused because the percentage is undefined; a negative cost is refused.
Why it runs in your browser
The arithmetic happens on this page with JavaScript. Your input is not posted to a server, so it works offline after the page loads and nothing is retained anywhere.
Profit margin expresses the difference between price and cost as a percentage of the selling price.
Cost and price are per unit in the same currency. Margin prints to four decimal places; a price below cost produces a negative margin rather than an error.
What the result means
Margin is always smaller than the equivalent markup because the denominator is the larger price figure. It measures the share of revenue kept before fixed costs.
How to use this calculator
Enter the cost and the price, then press Run.
Assumptions, rate basis and rounding
Cost and price are per unit in the same currency. Margin prints to four decimal places; a price below cost produces a negative margin rather than an error.
What to Expect
Best for
- Check the gross margin on a product before setting a price.
- Checking a quoted number before you act on it.
Not ideal for
- It does not include overhead, discounts, tax or volume.
- Decisions that need tax, legal or investment advice.
What this tool keeps
- Cost and price.
- The result is shown immediately; nothing is saved.
What may need cleanup
- Nothing: every run reads the fields fresh.
- Amounts must use one currency; no conversion is done.
Common errors
- A zero or negative price is refused because the percentage is undefined; a negative cost is refused.
- Entering a percentage as a decimal (0.06 instead of 6).
Example use cases
- Check the gross margin on a product before setting a price.
- Comparing two scenarios by changing one input at a time.
Sample input
80.00 cost and 100.00 price.
Sample output
Margin = 20.0000% (price 100.00, cost 80.00).
Who this is for
- Students and analysts checking a formula.
- Small-business owners and anyone comparing a quoted rate.
Frequently asked questions
What rate basis does this calculator use?
Cost and price are per unit in the same currency. Margin prints to four decimal places; a price below cost produces a negative margin rather than an error.
What input does it refuse?
A zero or negative price is refused because the percentage is undefined; a negative cost is refused.
Is margin the same as markup?
No. Margin divides profit by price; markup divides the same profit by cost. Margin is always the smaller percentage for a profitable sale.
Is this financial advice?
No. It is an arithmetic tool that applies the formula it states to the numbers you enter. It does not know your circumstances and does not recommend a product, a security or a course of action.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.