IQR outlier detection calculator
Spot the values that sit far outside the middle half of your data: in 1, 2, 2, 3, 4 and 100 the fences fall at −1 and 7, so 100 is the only outlier. Every quartile and fence is shown. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Values
- 1, 2, 2, 3, 4, 100
- Quantity
- 6
- Q1
- 2
- Q2
- 2.5
- Q3
- 4
The IQR outlier detection calculator identifies values that sit unusually far from the middle half of a numeric sample. It sorts a non-empty array, calculates Q1 and Q3 with the Tukey-exclusive convention, finds the interquartile range, and builds lower and upper fences at 1.5 times that range. Any value strictly outside those fences is flagged as an outlier. The response includes the quartiles, IQR, fences, flagged values, and count, making the result easy to inspect or automate without assuming that the data follows a normal distribution.
How the 1.5 IQR outlier rule works
Outlier detection with the interquartile range begins by sorting the submitted numbers from smallest to largest. The calculator finds Q2, the median of the complete sample, then finds Q1 from the lower half and Q3 from the upper half. For an odd-sized sample, the central median is excluded from both halves; this is the Tukey-exclusive convention used by this capability.
The interquartile range, or IQR, is Q3 minus Q1 and describes the width of the middle fifty percent of observations. The lower fence is Q1 minus 1.5 times the IQR, while the upper fence is Q3 plus 1.5 times the IQR. A submitted value is flagged only when it is strictly below the lower fence or strictly above the upper fence.
Values equal to either fence remain unflagged. This rule is useful because the quartiles are less sensitive to isolated extreme values than the arithmetic mean and standard deviation. The response exposes Q1, Q2, Q3, the IQR, both fences, the outlier array, and its count so every classification can be checked directly.
Prepare the array and interpret the response
Integers, decimals, negative values, repeated observations, and a one-item sample are accepted. Strings that merely look numeric are rejected, as are null, infinity, NaN, missing input, and arrays longer than the published limit. Strict validation prevents silent coercion from changing statistical meaning.
The calculation sorts an internal copy, so the order of the input does not affect the answer. The returned count is the number of observations. Q1, Q2, and Q3 identify the lower quartile, median, and upper quartile.
A single value produces identical quartiles and fences, an IQR of zero, and no outlier. Keep the quartile method in mind when comparing results with spreadsheet software, because applications can use different percentile interpolation conventions.
Use the flags as evidence, not an automatic deletion list
An IQR flag says that a value is far from the central portion of this particular sample; it does not prove that the observation is wrong. In a quality-control feed, a flagged measurement might reveal a failed sensor, but it might also capture a genuine process excursion that deserves investigation. In sales data, a very large order can be a legitimate enterprise purchase rather than a data-entry mistake.
Review flagged records against their source and domain context before removing, replacing, or winsorizing them. The rule also has limitations with very small samples, strongly multimodal data, and groups whose values should not have been combined. Consider calculating fences separately for meaningful cohorts such as device model, region, or experiment condition.
Repeated values are retained because frequency matters, and strict comparisons mean a value exactly on a fence is not an outlier. For reproducible pipelines, save the returned quartiles and fences alongside the flags rather than storing only a cleaned array. This creates an audit trail showing why each value was classified.
The calculator is best used as a transparent screening step before visualization, validation, or deeper modeling, not as an opaque command to discard unusual observations.
What you can do with it
Screen sensor readings
Flag measurements beyond the batch's IQR fences before reviewing calibration, transmission, or process anomalies.
Check imported business data
Spot unusually large or small amounts that may represent typing errors, unit mismatches, or legitimate exceptional transactions.
Teach robust statistics
Show students how quartiles, the IQR, and Tukey fences lead to a reproducible list of flagged observations.
FAQ
What values are classified as outliers?
Values strictly below Q1 minus 1.5 times the IQR or strictly above Q3 plus 1.5 times the IQR are classified as outliers.
What happens to a value exactly on a fence?
It is not flagged. The comparison is strict, so only values outside the lower or upper fence are outliers.
Which quartile convention does the calculator use?
It uses Tukey-exclusive halves: when the sample size is odd, the overall median is excluded when calculating Q1 and Q3.
Does a flagged value have to be removed?
No. A flag identifies an unusual observation, not necessarily an error. Investigate its source and context before changing the data.
Why does my spreadsheet flag different values?
Spreadsheets use various ways to interpolate quartiles, and a slightly different Q1 or Q3 moves the fences. This calculator always uses the Tukey-exclusive convention, leaving the median out of both halves when the count is odd.
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/iqr-outlier-detection \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"values":[1,2,2,3,4,100]}'const res = await fetch("https://api.kit.forhosting.com/stat/iqr-outlier-detection", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"values": [
1,
2,
2,
3,
4,
100
]
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/stat/iqr-outlier-detection",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"values": [
1,
2,
2,
3,
4,
100
]
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/stat/iqr-outlier-detection", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"values":[1,2,2,3,4,100]}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"values":[1,2,2,3,4,100]}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/stat/iqr-outlier-detection", 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,
2,
2,
3,
4,
100
]
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "stat.iqr_outlier_detection",
"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
Prepare the array and interpret the response
Send one field named values containing a non-empty JSON array of finite numbers. The lower_fence and upper_fence fields provide the exact classification boundaries, and outliers contains flagged values in ascending order, including duplicates when the same unusual observation occurs more than once. An empty array produces an invalid_input error because quartiles do not exist without observations.
Technical questions
Why does an empty array return an error?
Quartiles and the IQR are undefined when there are no observations, so an empty array returns invalid_input.
How much does an API request cost?
Each successful request costs $0.002. The calculator can also run free in the browser using the same deterministic logic.