Margin Calculatorby Tech Media Daily

Methodology

Every formula this calculator uses, how it rounds, and what it does when a calculation is impossible.

The formulas

All six calculation modes resolve to a cost and a selling price, and every other figure is derived from that pair. There is one code path, not six.

profit = selling price − cost
margin % = profit ÷ selling price × 100
markup % = profit ÷ cost × 100

Working backwards from a target:

selling price = cost ÷ (1 − margin)
maximum cost = selling price × (1 − margin)
selling price = cost × (1 + markup)

Converting between the two percentages:

markup = margin ÷ (1 − margin)
margin = markup ÷ (1 + markup)

Contribution margin

The advanced panel subtracts the variable cost of making a sale from gross profit:

contribution profit = gross profit − shipping − packaging − fees − advertising − other

Percentage fees are applied to net revenue, not to the tax-inclusive price. Where a price is entered inclusive of tax, tax is removed first: net revenue = price ÷ (1 + rate). Discounts are applied to the price before tax is extracted, because that is the order in which they happen at the till.

This calculator does not produce operating or net margin. Both require overheads it does not ask for, and a figure built on an assumed overhead would be worse than no figure.

Rounding

All arithmetic runs in double-precision floating point. Rounding happens only when a figure is displayed — never mid-calculation, and never fed back into a later step. Currency is shown to the conventions of the selected region; percentages to two decimal places. A displayed result re-entered as an input reproduces the original figures to two decimal places.

Impossible and edge cases

SituationWhat the calculator does
Selling price is zeroMargin is undefined rather than infinite. Profit is still shown.
Cost is zeroMargin is 100%. Markup is reported as not applicable, not as infinity.
Target margin of 100% or moreRefused, with an explanation. The formula would divide by zero.
Negative target marginAllowed. Deliberate loss-leader pricing is a real decision.
Selling below costNegative profit and margin are shown and labelled as a loss.
Negative cost or price enteredRejected at the field.
A field is emptyTreated as not yet answered, not as an error.

No calculation returns NaN, infinity, or a blank where a number should be. The engine is covered by an automated test suite that asserts this for every case above.

Tax figures

The tax rate shown for each region is a starting value, not advice, and is editable. Rates change and vary by product and by business. Confirm the rate that applies to you with the relevant tax authority or your accountant before relying on any figure here.

Who maintains this

The calculator is built and maintained by Tech Media Daily. Formulas and worked examples were last reviewed on 27 August 2026. If you find an error, tell us — corrections are made and the review date updated.

This calculator provides estimates for informational purposes and is not financial, tax, accounting, legal or investment advice.

← Back to the calculator