Interquartile Range (IQR) Calculator

Interquartile range (IQR)1.50
First quartile Q14.00
Median4.50
Third quartile Q35.50
Lower outlier fence1.75
Upper outlier fence7.75
How this was calculated
  1. Sorted data: 2, 4, 4, 4, 5, 5, 7, 9 — quartiles are read from the ordered list, never from the raw entry order.
  2. Q1 (25th percentile) = 4.00, the median = 4.50, and Q3 (75th percentile) = 5.50, using linear interpolation between the closest ranks.
  3. IQR = Q3 - Q1 = 5.50 - 4.00 = 1.50 — the spread of the middle half of the data, untouched by the extremes.
  4. Outlier fences sit at Q1 - 1.5 x IQR = 1.75 and Q3 + 1.5 x IQR = 7.75.
  5. Values outside the fences: 9 — Tukey's rule flags these as outliers worth a second look, not automatic deletions.
  6. Because the IQR ignores the top and bottom quarters entirely, it pairs with the median the way the standard deviation pairs with the mean — the honest spread for skewed data.

This interquartile range calculator takes your data set and returns the interquartile range (IQR), the spread of the middle 50% of a data set. The IQR is Q3 minus Q1, and it is immune to the extremes by construction. Along with the IQR, the calculator reports Q1 and Q3, the median, and Tukey's fences for flagging outliers: values below Q1 minus 1.5 times the IQR or above Q3 plus 1.5 times the IQR are marked for a second look. On a box plot, the IQR is literally the length of the box, and the fences are where the whiskers stop. The IQR pairs with the median the way standard deviation pairs with the mean, making it the honest spread for skewed data such as incomes and prices.

Quartiles here use the linear-interpolation (type 7) percentile method, the default in R, NumPy and most spreadsheet percentile functions. Naming the method matters because different quartile conventions, of which there are at least nine percentile definitions, give slightly different Q1 and Q3 on small samples. This page shows the formula, step-by-step workings, worked examples and sources so you can verify every result and understand exactly how the numbers were computed.

Worked examples

Textbook eight values

Primary result: 1.50 — Q1 4.00, median 4.50, Q3 5.50 — and the 9 sits outside the 7.75 fence. (8 values · 2 · 4 · 4 · 4 · 5 · 5 · 7 · 9)

Interquartile range (IQR)1.50
First quartile Q14.00
Median4.50
Third quartile Q35.50
Lower outlier fence1.75
Upper outlier fence7.75

Five evenly spaced values

Primary result: 20.00 — a perfectly even spread gives an IQR of 20.00, with fences far outside the data. (5 values · 10 · 20 · 30 · 40 · 50 · 0 · 0 · 0)

Interquartile range (IQR)20.00
First quartile Q120.00
Median30.00
Third quartile Q340.00
Lower outlier fence-10.00
Upper outlier fence70.00

Six values, no outliers

Primary result: 8.50 — Q1 5.75 to Q3 14.25 — an IQR of 8.50 and nothing flagged. (6 values · 3 · 5 · 8 · 12 · 15 · 20 · 0 · 0)

Interquartile range (IQR)8.50
First quartile Q15.75
Median10.00
Third quartile Q314.25
Lower outlier fence-7.00
Upper outlier fence27.00

How quartiles and the IQR are calculated

Every interquartile range calculator starts the same way: by sorting the data from smallest to largest. Once the values are in order, the tool locates three landmarks — the first quartile (Q1), the median, and the third quartile (Q3). The interquartile range is Q3 minus Q1: the spread of the middle 50% of a data set, immune to the extremes by construction. Because it ignores the highest and lowest values, a single outsized number cannot inflate it the way a single value can inflate the range or standard deviation.

This page uses the linear-interpolation (type 7) percentile method — the default in R, NumPy and most spreadsheet percentile functions. On a sorted data set of n values, type 7 places Q1 at position 0.25 times (n plus 1), the median at 0.50 times (n plus 1), and Q3 at 0.75 times (n plus 1). When a position lands between two data points, the calculator interpolates between them. Different quartile conventions (there are at least nine percentile definitions) give slightly different Q1 and Q3 on small samples; the method must be named so results are reproducible and comparable across tools.

Consider a sorted data set of nine values: 3, 7, 8, 10, 12, 15, 16, 20, 45. With n equal to 9, type 7 puts Q1 at position 2.5, which interpolates to 7.5 (halfway between 7 and 8). The median sits at position 5, which is 12. Q3 falls at position 7.5, interpolating to 18 (halfway between 16 and 20). The interquartile range is 18 minus 7.5, or 10.5. Tukey's fences then flag outliers: values below Q1 minus 1.5 times IQR or above Q3 plus 1.5 times IQR are marked for a second look. Here the lower fence is 7.5 minus 15.75, or negative 8.25, and the upper fence is 18 plus 15.75, or 33.75. The value 45 lands above the upper fence, so the calculator flags it as a potential outlier.

On a box plot, the IQR is literally the length of the box, and the fences are where the whiskers stop. The flagged value of 45 would appear as a separate point beyond the upper whisker rather than inside the box. The IQR pairs with the median the way standard deviation pairs with the mean — it is the honest spread for skewed data such as incomes and prices, where a few high values can pull a mean far above what most observations actually show.

Tukey's outlier fences

Tukey's fences are the most common way an interquartile range calculator flags outliers. The rule is simple: any value below Q1 − 1.5 × IQR or above Q3 + 1.5 × IQR gets marked for a second look. Because the interquartile range is Q3 minus Q1 — the spread of the middle 50% of a data set, immune to the extremes by construction — the fences sit a comfortable distance from the typical values. On a box plot, the IQR is literally the length of the box, and the fences are where the whiskers stop. Anything beyond the fences shows up as a plotted dot, which is why box plots remain the fastest visual outlier screen ever devised.

Here is what 'flagged' actually means: a value is unusual enough to deserve a closer inspection. It does not mean the value is wrong, fraudulent, or meaningless. A genuine outlier can be the most informative point in the entire data set — the patient who responded to the drug, the house that sold for 10 times the neighborhood median, the sensor reading that caught an equipment failure early. When you use an interquartile range calculator, treat every flagged value as a question, not a verdict. Investigate the source, check the data entry, and understand the context before you decide what to do.

Deleting outliers automatically is a statistical crime scene. Removing flagged values without investigation distorts the median, shrinks the IQR, and can push new points past the revised fences — a chain reaction that quietly erases the tails of your distribution. If you drop every value beyond Tukey's fences, you are not cleaning data; you are editing reality to fit a tidy story. The honest approach is to report outliers transparently, document any removal with a stated reason, and run analyses both with and without the flagged values when the decision is genuinely ambiguous.

One more caution: the fence positions depend on how Q1 and Q3 are computed. Quartiles here use the linear-interpolation (type 7) percentile method — the default in R, NumPy and most spreadsheet percentile functions — but different quartile conventions exist. There are at least nine percentile definitions, and they give slightly different Q1 and Q3 on small samples. Always name the method, because two researchers using the same data can flag different points as outliers simply by switching conventions. The IQR pairs with the median the way standard deviation pairs with the mean — it is the honest spread for skewed data such as incomes and prices — but only if the quartile method is explicit.

IQR vs standard deviation and range

Three common measures describe how spread out a data set is, but each looks at a different portion of the data. The range uses two values: the maximum and the minimum. It is simple to compute, but a single extreme point can stretch it wildly, making it a poor summary for messy or skewed data. The interquartile range uses the middle half instead. Because the interquartile range is Q3 minus Q1, it captures the spread of the middle 50% of a data set and is immune to the extremes by construction. Standard deviation uses everything: every value contributes to the calculation, so it is sensitive to both the center and the tails.

Which measure you should report depends on the shape of your data. The IQR pairs with the median the way standard deviation pairs with the mean — it is the honest spread for skewed data such as incomes and prices. When the data is roughly symmetric and the mean is a sensible center, standard deviation is the natural companion. When the data is skewed or contains outliers, the median and IQR give a more faithful picture. An interquartile range calculator will handle the skewed case automatically, but the method behind it matters: quartiles here use the linear-interpolation (type 7) percentile method — the default in R, NumPy and most spreadsheet percentile functions. Different quartile conventions (there are at least nine percentile definitions) give slightly different Q1 and Q3 on small samples; the method must be named.

These spreads also connect to outlier detection and visualization. Tukey's fences flag outliers: values below Q1 − 1.5 x IQR or above Q3 + 1.5 x IQR are marked for a second look. On a box plot, the IQR is literally the length of the box, and the fences are where the whiskers stop. The range, by contrast, is just the distance from the lowest to the highest point, with no built-in screening. Standard deviation has its own outlier rules, but because it uses every value, those rules can fail when the data is heavily skewed.

Reading a box plot

A box plot compresses an entire data set into one picture, and every part of it maps directly to the numbers our interquartile range calculator produces. The box itself is the IQR — its length equals Q3 minus Q1, the spread of the middle 50% of the data. The line inside the box marks the median. The whiskers stretch out to the fences, which are the most extreme values still within Tukey's limits. Values beyond those fences show up as individual points, flagged for a second look as potential outliers.

Tukey's fences set the boundary at Q1 minus 1.5 times the IQR on the low end and Q3 plus 1.5 times the IQR on the high end. Anything outside those lines is plotted on its own rather than absorbed into a whisker. This is what makes the box plot so useful for skewed data such as incomes and prices: the IQR pairs with the median the way standard deviation pairs with the mean, but it is immune to the extremes by construction. A long whisker on one side tells you the data stretches in that direction, while a cluster of points beyond the fence tells you exactly how many values stand apart from the rest.

One detail matters when you compare box plots or feed data into a tool like this interquartile range calculator: the quartile method. There are at least nine percentile definitions in common use, and they give slightly different Q1 and Q3 values on small samples. The method must be named. Here we use the linear-interpolation type 7 method, which is the default in R, NumPy and most spreadsheet percentile functions. If another source produced a box plot using a different convention, the box edges and whisker tips may not line up exactly — the difference is the math, not the data.

So when you read a box plot, read it as one picture that contains this entire page. The box length is the IQR. The center line is the median. The whiskers reach the fences. The dots beyond the fences are the outliers Tukey's rule caught. Quartiles here use the type 7 method. That is the whole story in a single frame.

FAQs

What is the interquartile range?

The interquartile range is Q3 minus Q1 — the range covering the middle 50% of the data. For 2, 4, 4, 4, 5, 5, 7, 9 the quartiles are 4 and 5.5, so the IQR is 1.5. It measures spread by focusing on the central portion of the data.

How do I find Q1 and Q3?

Sort the data, then take the 25th and 75th percentiles. With linear interpolation, Q1 sits a quarter of the way through the ordered list and Q3 three-quarters through. This gives you the two values needed to calculate the interquartile range.

What are Tukey's fences used for?

They flag possible outliers: anything below Q1 − 1.5 x IQR or above Q3 + 1.5 x IQR. Flagged values deserve investigation, not automatic deletion. The fences help identify data points that fall unusually far from the middle spread.

Why use IQR instead of standard deviation?

The IQR ignores the top and bottom quarters entirely, so one extreme value cannot inflate it. For skewed data like incomes, IQR with the median describes the spread more honestly than standard deviation, which is sensitive to outliers.

Does the IQR depend on the quartile method?

Slightly, on small samples. This page uses the type-7 linear interpolation method (the R and NumPy default); other conventions can differ by a fraction of a unit. The choice of method matters most when working with smaller data sets.

What does an IQR of zero mean?

The middle half of the data has no spread at all — at least half the values are identical, as in a data set dominated by one repeated number. A zero IQR signals that the central portion of the data lacks variation.

Sources

Related calculators

Variance Calculator
Sample and population variance for up to eight values, with both standard deviations and the full sum-of-squares workings.
Standard Deviation Calculator
Mean, sample and population standard deviation and variance for up to eight numbers — with the n versus n−1 difference explained.
Fraction to Decimal Calculator
Any fraction as a decimal, a percentage and a mixed number — with the simplification shown and a note on whether the decimal terminates or repeats.