Median calculator
For 1, 3, 3, 6, 7, 8 and 9 the median is 6, with three values on each side. Paste the numbers in any order: they are sorted for you, and an even count takes the average of the two middle values. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
The median is the middle value of a data set once every number has been placed in order. Unlike the arithmetic mean, it does not lean toward a single huge or tiny observation, so it is the robust center that teachers, analysts, and journalists reach for when a salary list, a test score sheet, or a sensor sample is skewed. This calculator accepts a non-empty list of finite numbers, sorts a copy, and returns the unique middle entry when the count is odd, or the average of the two central entries when the count is even. An empty list is rejected with a clear validation error instead of inventing a middle from nothing.
How the median of a list is computed
Begin with a non-empty collection of finite real numbers and sort a copy into ascending order. When the count n is odd, the median is the single order statistic at one-based rank (n + 1) / 2, which sits at zero-based index (n − 1) / 2. That unique middle value splits the ordered sample so that equally many observations sit on either side.
When n is even there is no single middle slot, and the conventional statistical definition takes the arithmetic mean of the two central ranks: the n/2-th value and the (n/2 + 1)-th value. That average is the unique number that still leaves the same count of observations on the low side and the high side. Duplicate values are kept, because two identical scores occupy two ranks and can themselves be the middle pair.
A one-element list is already ordered and its only value is the median. Every token must be a finite number: missing fields, empty arrays, non-numeric strings, NaN, and Infinity fail the same way. There is no interpolation beyond the even-n average, no weighting, and no trimmed-mean variant on this landing.
Where the median is the right center in real work
Labor economists and journalists report typical wages with the median because a handful of very high salaries would drag the mean far above what most people earn. Quality teams and sensor pipelines use the median as a robust location estimate when a spike, a drop-out, or a mis-calibrated reading would ruin an arithmetic average. Product analysts summarizing session lengths, cart values, or latency samples often prefer the middle of the ordered list for the same reason.
If you later need the mean and mode together, a five-number summary, quartiles, or a percentile other than fifty, treat those as separate search intents and landings rather than overloading this median calculator page.
What you can do with it
Homework and exam answer keys
Generate the median for odd and even classroom lists so teachers and auto-graders share one ground truth, including the two central values used when n is even.
Salaries and other skewed samples
Report a typical wage, house price, or wait time with the middle order statistic instead of an arithmetic mean that a few extreme observations would pull aside.
FAQ
What is the median of a list of numbers?
After sorting, it is the unique middle value when the count is odd, or the average of the two central values when the count is even. It is the robust center of a numeric sample.
How is the median computed when the list has an even count?
There is no single middle slot. This calculator averages the two central order statistics (ranks n/2 and n/2+1).
Why choose the median instead of the mean?
The median depends only on order, so one huge or tiny observation cannot drag it the way it can drag the arithmetic mean. Use it on skewed wages, prices, or noisy sensor samples.
What happens if I send an empty list?
The median of no observations is undefined. Failed validation is not charged.
What does a request cost?
The browser tool is free and runs locally.
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/median \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"values":[1,3,3,6,7,8,9]}'const res = await fetch("https://api.kit.forhosting.com/stat/median", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"values": [
1,
3,
3,
6,
7,
8,
9
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/median",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"values": [
1,
3,
3,
6,
7,
8,
9
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/median", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"values":[1,3,3,6,7,8,9]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"values":[1,3,3,6,7,8,9]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/median", 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,
3,
3,
6,
7,
8,
9
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.median",
"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.
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 free browser tool and the prepaid API share one deterministic function with no network, no random seed, and no clock, so homework checks and production pipelines never disagree on the same numbers.
How the median of a list is computed
An empty list has no order statistics at all, so this engine throws invalid_input rather than returning zero, NaN, or a silent default. The comparison is a numeric sort on a copy, the original sequence is never mutated, and the same payload always produces the same JSON.
What you send and what you get back
Numeric strings inside the array are coerced, and a comma, space, or semicolon separated string is also accepted for simple text forms. Classic textbook checks include one, three, three, six, seven, eight, nine whose median is six, and the even list one, two, three, four whose median is two point five. A single-element list such as forty-two returns forty-two with even false. Send a JSON body with one required field named values: a non-empty array of finite numbers. Aliases numbers, data, and list are accepted and behave the same. On success the response includes count as n, values as the ascending sorted copy used for the calculation, median as the primary result, even as a boolean that is true only when n is even, mid_low and mid_high as the two central order statistics (identical when n is odd), a method label of middle_order_statistic or average_of_two_central, and a short formula string. Failed validation — missing values, an empty list, non-finite entries, or a list longer than one hundred thousand numbers — returns invalid_input and is never charged.
Where the median is the right center in real work
Secondary-school and college statistics courses constantly assign median drills, odd-versus-even comparisons, and word problems that contrast the median with the mean on a skewed list; a single trusted oracle that returns cleaned JSON speeds grading and demo setup. Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.
Integration use cases
Sensor readings with outliers
Summarize a short numeric sample from a probe or log when a single spike should not move the reported center, and keep the same result in the browser and the API.