ForHosting KIT · Math

Percentage calculator

Six percentage questions in one place: how much 20% of 150 is (30), what share one number is of another, how much something rose or fell, and what it cost before a percentage was added. 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
Value
150
Calculation
X% of a value
Percent (%)
20
You get
Result
30

Computes percentages in six modes from numeric inputs: percent of a value, what percent one number is of another, percent change between two numbers, a percent increase or decrease, and reverse (strip an added percent). Rounded half-up to a chosen number of decimals.

The six questions behind almost every percentage

Most percentage problems are one of six questions. What is 20% of 150? What percent is one number of another, like a score out of a total? By how much did a price or a salary change? What is a figure after an increase, or after a discount? And the one that trips people up most: what was the price before a percentage was added, such as a tax or a markup. There is an option for each, so you choose the question instead of rearranging a formula.

The classic percentage mistakes, avoided

A rise followed by a fall of the same percentage does not bring you back to the start, because the fall is taken from a bigger base. Removing a tax is not the same as subtracting its rate: you divide by one plus the rate, which is what the reverse option does. Percent change always uses the old value as its base, so the order of the two numbers matters. Results are rounded to the number of decimals you choose, two by default.

What does reverse mode do?

It returns value / (1 + percent/100), recovering the base amount before a percent was added, such as stripping an included tax or markup.

How is rounding handled?

Half-up on the computed value to the decimals you choose (0 to 10, default 2), applied by magnitude so negatives round away from zero.

Which fields does each mode need?

of, increase, decrease and reverse use percent and value; is and change use operands a and b. Others are ignored.

How do I find 20% of 150?

Pick the percent-of-a-value option, enter 20 as the percent and 150 as the value, and the result is 30. The same option works for a tip, a commission or any share of a total.

How do I work out the percentage increase between two numbers?

Use the percent change option and enter the old number first and the new one second. The difference is divided by the old number, so you get a positive result for a rise and a negative one for a fall.

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/percentage

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/percentage \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode":"of","percent":20,"value":150}'
{
  "mode": "of",
  "percent": 20,
  "value": 150
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "dev.percentage",
  "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.

max_abs1000000000000000
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.

The six modes and their formulas

The mode field selects one of six calculations. mode="of" returns value * percent / 100 (e.g. 20% of 150 = 30). mode="is" returns a / b * 100, the percentage a represents of b. mode="change" returns (b - a) / a * 100, the percent change from an old value a to a new value b. mode="increase" returns both delta = value * percent / 100 and result = value * (1 + percent/100). mode="decrease" returns delta and result = value - delta. mode="reverse" returns value / (1 + percent/100), which recovers the base amount before a percent was added, useful for stripping a markup or tax already baked into a figure. Each mode echoes its inputs in the JSON response alongside the computed result so the payload is self-describing.

Inputs, rounding and which fields each mode needs

The optional decimals field defaults to 2 and must be an integer from 0 to 10. Every numeric field must be a finite number; magnitudes above 1e15 are rejected as out of range to keep results meaningful and the tab responsive. of/increase/decrease/reverse read percent and value; is and change read operands a and b. The response returns the plain numeric result (and delta for increase/decrease), never a formatted string, so downstream code can do further math without reparsing.

Validation, division by zero and typed errors

A missing or non-object input, a non-finite number, a decimals value outside 0..10, or an out-of-range magnitude are all caught before arithmetic runs. An unknown mode string is rejected outright. Bad input throws a typed invalid_input error with a message naming the field, never an untyped crash. Three modes guard against division by zero: mode="is" rejects b=0, mode="change" rejects an old value a=0, and mode="reverse" rejects a percent of -100 (which makes 1 + percent/100 zero).

Discounts and markups

Use mode=of for a discount amount, or mode=reverse to recover a pre-markup base price from a total.

Growth and change reporting

Feed old and new figures into mode=change to report period-over-period percent change in dashboards.

Proportions and shares

mode=is answers what percent one number is of another, e.g. a completed count against a total.

When do I get an error?

You get a typed invalid_input error for non-finite numbers, decimals outside 0..10, magnitudes over 1e15, or division by zero (b=0 in is, a=0 in change, -100% in reverse).

Is it free and how much is the API?

The browser widget is free; the API runs on prepaid KIT balance from $0.002 and failed tasks are not charged.

Read the full KIT documentation →