Pie chart percentage calculator
The amounts 1, 1 and 2 add up to 4, so they become a quarter, a quarter and half of the pie. Paste your category values and get slice percentages that always total exactly 100, never 99.99. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Values
- 1, 1, 2
- Total
- 4
- N
- 3
- Percentages
- 25, 25, 50
- Shares
- 0.25, 0.25, 0.5
A pie chart is only honest when every slice is a percentage of one shared total and those percentages add to exactly one hundred. This pie chart percentage calculator accepts a list of category values — regional sales, survey counts, budget lines, vote tallies, or any non-negative weights — adds them once, then converts each entry into one hundred times that value divided by the total. The last non-zero slice absorbs the microscopic rounding residue so the returned percentages always sum to 100 instead of 99.99 or 100.01.
What a pie-chart percentage is and why the slices must add to 100
A pie chart encodes a composition: each slice is a category's share of one whole, and the whole is the sum of the category values you supplied. The percentage for category i is one hundred times that value divided by the sum of all values. That identity is the same whether the raw numbers are counts, currency amounts, minutes, or unitless weights, because the units cancel in the ratio.
People reach for this conversion when they already have a column of amounts and need the labels that sit on the pie, the legend, or a stacked-bar twin of the same composition. Geometry class often asks for the same shares as central angles in degrees; this calculator answers the percentage form of that question, which is what dashboards, slide decks, and survey reports actually print next to each slice. Two hard constraints keep the picture honest.
First, every value must be a finite number greater than or equal to zero: a negative slice has no meaning on a pie and is rejected instead of being drawn backwards. Second, the total must be strictly positive. If every category is zero, there is no whole to take a percentage of, and the correct answer is an error, not a ring of invented equal slices.
After the exact ratios are formed, ordinary floating-point rounding can leave a last digit that makes the printed list add to 99.99 or 100.01. This implementation assigns that residue to the last non-zero category so the published percentages always sum to exactly 100, which is the contract a pie chart, a stacked bar, and a composition table all require before anyone trusts the picture.
What you can do with it
Homework and composition problems
Students convert a short list of category counts into pie-chart percentages that sum to 100, including the hard rule that a zero total is invalid.
Dashboards and survey reports
Product and research teams turn sales, votes, or budget lines into legend percentages without a spreadsheet and without a leftover 99.99 percent.
FAQ
What is the pie chart percentage formula?
Each percentage is 100 times that category value divided by the sum of all values. The last non-zero slice is adjusted so the published percentages sum to exactly 100.
Do the percentages always add up to 100?
Yes on success. Zero slices stay at 0 percent.
Is the pie chart percentage calculator free?
The browser tool runs free on your device.
What happens if all my values are zero?
You get an error instead of a chart. With a total of zero there is no whole to take a share of, so the calculator refuses to invent equal slices.
Can I enter amounts of money or minutes instead of counts?
Yes. Each share is the value divided by the total, so the units cancel out: counts, money amounts, minutes or plain weights all give the same kind of percentage.
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/stat/pie-chart-percentage \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"values":[1,1,2]}'const res = await fetch("https://api.kit.forhosting.com/stat/pie-chart-percentage", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"values": [
1,
1,
2
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/pie-chart-percentage",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"values": [
1,
1,
2
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/pie-chart-percentage", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"values":[1,1,2]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"values":[1,1,2]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/pie-chart-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
{
"values": [
1,
1,
2
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.pie_chart_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_values | 1000 |
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
When every value is zero the total is zero and the request fails with invalid_input, because a pie with no mass has no defined shares. The same pure function powers the free browser tool and the API path at $0.002 per successful request.
Input contract, formula, rounding, and the zero-total error
After validation the engine adds the list once to obtain the total. Otherwise each percentage is one hundred times the value divided by the total, rounded to ten decimal places for a stable contract across runtimes. The last non-zero slice is then rewritten as one hundred minus the sum of the others so the vector of percentages sums to 100 even when one-third repeating would otherwise leave a leftover ultralow digit. Zero individual categories are allowed and stay at zero percent; they never receive the rounding residue. Call the capability with a required field named values: a non-empty array of finite, non-negative numbers. Scripts that already speak in other terms can send the same list under the aliases numbers, data, counts, or list. A missing field, a non-array, an empty array, a list longer than the published maximum of one thousand entries, any entry that is not a finite number, and any negative entry all fail with invalid_input and do not consume balance. If that total is not strictly greater than zero, the request fails with a message that the total of all values is zero, because each percentage is one hundred times the value divided by the total and that division is undefined when the denominator is zero. The response echoes n and values, reports total, percentages, the corresponding unit shares (each value over the total), sum_percent (always 100 on success), and a short formula string.
Practical use, limits, pricing, and how to read the result
Use the browser tool when you want an immediate pie-chart percentage while building a slide, checking a homework composition problem, or turning a short column of counts into legend labels without opening a spreadsheet. Each successful request is one billable item at $0.002; failed validation does not consume balance. Accepted lists stay bounded for Worker isolates: up to one thousand categories cover any pie that a human can still read, and lists larger than that belong in a table rather than a circular chart. Results are fully deterministic: the same values always yield the same total, the same percentages, the same shares, and the same sum_percent of one hundred. Wire the endpoint into report builders that already have amounts and need percentages, into classroom oracles that mark the twenty-five / twenty-five / fifty split from the values one, one, and two, or into a preprocess step that rejects an all-zero column before a renderer tries to draw an empty pie. Read percentages for the labels you print on the chart, shares if you need a zero-to-one fraction for further math, and sum_percent as a quick integrity check that the rounding fix ran.
Integration use cases
Scripts and CI fixtures
Pipelines call a deterministic percentage contract instead of reimplementing value-over-total rounding in every language.
Technical questions
How do I compute pie chart percentages with this calculator?
Send JSON with values (a non-empty array of non-negative numbers whose total is greater than zero) to stat.pie_chart_percentage. The response returns n, values, total, percentages, shares, sum_percent, and formula.
What happens if the total of all values is zero?
The request fails with invalid_input because percentages are undefined when the sum is zero. Validation failures are not charged.