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
Run — free
Worked example
- Value
- 150
- Calculation
- X% of a value
- Percent (%)
- 20
- 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.
FAQ
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.
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/dev/percentage \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"mode":"of","percent":20,"value":150}'const res = await fetch("https://api.kit.forhosting.com/dev/percentage", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"mode": "of",
"percent": 20,
"value": 150
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/dev/percentage",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"mode": "of",
"percent": 20,
"value": 150
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/dev/percentage", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"mode":"of","percent":20,"value":150}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"mode":"of","percent":20,"value":150}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/dev/percentage", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"mode": "of",
"percent": 20,
"value": 150
}Example response
{
"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.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Limits
max_abs | 1000000000000000 |
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
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).
Integration use cases
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.
Technical questions
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.