How to use the median calculator
- Paste or type your numbers into the text area. Use newlines, commas, spaces, or tabs to separate values.
- Choose a delimiter if auto-detection doesn't match your format (rarely needed).
- Read the result: the median appears at the top, with count, min, max, and a preview of the sorted values below.
How the median is calculated
The median is the middle value of a sorted data set. For an odd number of values, it is the single middle number. For an even number, it is the average of the two middle numbers.
Example with 7 values: 3, 7, 8, 11, 12, 15, 19. The sorted position is (7 + 1) / 2 = 4, so the 4th value 11 is the median.
Example with 8 values: 1, 2, 3, 4, 5, 7, 8, 9. The two middle positions are 4 and 5, values 4 and 5. Their average (4 + 5) / 2 = 4.5 is the median.
This median calculator handles both cases automatically and shows the sorted values so you can verify the result.
When to use median instead of mean
The median is a robust measure of central tendency. It is not skewed by extreme outliers the way the arithmetic mean is. Use the median for:
- Income or house price distributions (a few billionaires or mansions distort the mean)
- Response times or latency data (occasional spikes should not shift the typical value)
- Survey responses on ordinal scales (1 to 5 ratings)
- Any data set where you want the typical value unaffected by extremes
For symmetric distributions without outliers, the median and mean are similar. For skewed data, the median better represents the center.
Reference: median vs mean for common distributions
The table below shows how median and mean differ for several example data sets.
| Data set | Sorted | Count | Median | Mean |
|---|---|---|---|---|
| 1, 2, 3, 4, 5 | 1, 2, 3, 4, 5 | 5 | 3 | 3 |
| 1, 2, 3, 4, 100 | 1, 2, 3, 4, 100 | 5 | 3 | 22 |
| 10, 20, 30, 40 | 10, 20, 30, 40 | 4 | 25 | 25 |
| 10, 20, 30, 1000 | 10, 20, 30, 1000 | 4 | 25 | 265 |
| -5, -2, 0, 3, 8 | -5, -2, 0, 3, 8 | 5 | 0 | 0.8 |
Common mistakes and edge cases
Empty input returns an error. At least one valid number is required.
Non-numeric text (letters, hex such as 0x1F, thousands separators) causes an error. Use a decimal point rather than a decimal comma, because commas split the list. Clean your data before pasting.
Single value returns that value as the median. Count will be 1.
Duplicate values are treated normally; each occurrence counts toward the position.
Very large data sets (thousands of values) work fine in the browser, but the sorted preview shows only the first 50 values to keep the page responsive.
Scientific notation like 1e3 or 2.5E-2 is parsed correctly by JavaScript's number parser.
Worked examples
| Example | Input | Result |
|---|---|---|
| Odd count (7 values) | Numbers (one per line or comma-separated): 12 / 7 / 19 / 3 / 11 / 8 / 15; Delimiter: auto | Median: 11; Count: 7; Minimum: 3; Maximum: 19; Sorted preview: 3, 7, 8, 11, 12, 15, 19 |
| Even count (8 values) | Numbers (one per line or comma-separated): 5, 2, 9, 1, 7, 3, 8, 4; Delimiter: auto | Median: 4.5; Count: 8; Minimum: 1; Maximum: 9; Sorted preview: 1, 2, 3, 4, 5, 7, 8, 9 |
| Decimals and negatives | Numbers (one per line or comma-separated): -2.5 / 0 / 3.14 / -1 / 2.5; Delimiter: auto | Median: 0; Count: 5; Minimum: -2.5; Maximum: 3.14; Sorted preview: -2.5, -1, 0, 2.5, 3.14 |
| Large data set (20 values) | Numbers (one per line or comma-separated): 23 45 12 67 34 89 11 56 78 90 12 34 56 78 90 11 23 45 67 89; Delimiter: space | Median: 50.5; Count: 20; Minimum: 11; Maximum: 90; Sorted preview: 11, 11, 12, 12, 23, 23, 34, 34, 45, 45, 56, 56, 67, 67, 78, 78, 89, 89, 90, 90 |
| Single value | Numbers (one per line or comma-separated): 42; Delimiter: auto | Median: 42; Count: 1; Minimum: 42; Maximum: 42; Sorted preview: 42 |
FAQ
What is the difference between median and average?
The median is the middle value when data is sorted. The average (arithmetic mean) is the sum divided by the count. The median ignores extreme values; the average incorporates every value equally.
How do I find the median of an even number of values?
Sort the values, take the two middle numbers, add them together, and divide by two. For example, with 1, 3, 5, 7 the middle values are 3 and 5, so the median is (3 + 5) / 2 = 4.
Can the median be a decimal even if all inputs are integers?
Yes. When the count is even and the two middle integers are not equal, their average can be a decimal (e.g., 3 and 4 give 3.5).
Does the calculator handle negative numbers and decimals?
Yes. Negative numbers sort correctly (e.g., -5 comes before -2). Decimals are parsed and sorted numerically. Scientific notation like 1e3 is also accepted.
What happens if I have duplicate values?
Each occurrence is counted separately. For example, in 1, 2, 2, 3 the sorted list has four values; the middle positions are the two 2s, so the median is 2.
Is there a limit to how many numbers I can enter?
The tool handles thousands of values in the browser. The sorted preview displays the first 50 values for readability, but the median calculation uses the full list.
When should I use this median calculator instead of a mean calculator?
Use this median calculator when your data has outliers or is skewed (income, house prices, response times). Use a mean calculator for symmetric distributions without extreme values, or when you need a measure that uses all data points for further statistical calculations.