Calcist

Style

Buttons

Spacing

How much to show

Decimal places

Text size

Confidence interval calculator

Get the confidence interval and margin of error for a mean (t or z) or for a proportion (Wilson score and Wald), at any confidence level.

Confidence interval for a mean

Confidence interval for a proportion

Private: calculated on your device. Nothing you type is sent anywhere.

Next: Planning a study? Find how many responses you need with the sample size calculator.

Confidence interval for a mean

x ± t* × s ÷ √n (sample standard deviation, df = n − 1)
x ± z* × σ ÷ √n (known population σ)

Use t whenever the standard deviation comes from your own sample, which is nearly always. The t critical value is larger than z for small samples, which widens the interval to allow for the extra uncertainty. This calculator computes t* exactly for any degrees of freedom (no table lookup), so you aren't limited to the rows of a printed table.

Example: a sample of 25 has a mean of 100 and a standard deviation of 15. At 95% with 24 degrees of freedom, t* = 2.0639. The standard error is 15 ÷ √25 = 3, so the margin is 2.0639 × 3 = 6.19 and the interval is 93.81 to 106.19. With z* = 1.96 it would be slightly narrower: 94.12 to 105.88.

Confidence interval for a proportion

Wilson: ( p̂ + z²/2n ± z √( p̂(1 − p̂)/n + z²/4n² ) ) ÷ ( 1 + z²/n )
Wald: p̂ ± z √( p̂(1 − p̂)/n )

The Wald interval is the one in many textbooks, but it performs poorly for small samples and for proportions near 0% or 100%. It can even give a lower limit below 0. The Wilson score interval keeps close to the promised coverage in those cases, which is why statisticians (Brown, Cai and DasGupta, 2001) and the NIST handbook recommend it. For large samples with a proportion near the middle, the two agree closely.

Example: 50 yes answers out of 100 at 95%: Wilson gives 40.38% to 59.62%, and Wald gives 40.20% to 59.80%. With 0 out of 10, Wald gives the useless 0% to 0%, while Wilson gives 0% to 27.75%.

Common critical values

Confidencez*t* (df = 9)t* (df = 29)
90%1.64491.83311.6991
95%1.96002.26222.0452
99%2.57583.24982.7564

What a confidence interval doesn't tell you

  • It covers sampling error only. A biased sample, such as an online poll, can be confidently wrong.
  • The t interval assumes the data is roughly normal, or that the sample is big enough (about 30 or more) for the mean to behave normally. Very skewed data needs more.
  • A 95% interval doesn't mean 95% of the data lies inside it. It's about the mean, not individual values.

Sources

How we checked this

Before every update, this calculator is run in a real browser with these known answers, and it must match all of them:

  • Mean 100, s = 15, n = 25, 95% t: 93.808304 to 106.1917 ✓
  • Same with known σ (z): 94.120108 to 105.87989 ✓
  • 50 of 100, 95% Wilson: 40.3832% to 59.6168% ✓
  • 5 of 20, 99% Wilson: 8.73639% to 53.7189% ✓
  • 0 of 10, 95% Wilson: 0% to 27.7533% ✓

Last checked October 26, 2026. Spotted something wrong? The math is done in your browser with the formula shown on this page, so you can check any result by hand.

Add this calculator to your website (free)

Paste this code into any web page. The calculator works on your page, resizes itself, has no ads and no tracking, and nothing your visitors type is sent anywhere. More about embedding.

Questions people ask

How do I calculate a 95% confidence interval?

Take the mean, then add and subtract the critical value times the standard error (SD ÷ √n). For a sample SD, the critical value comes from the t distribution with n − 1 degrees of freedom.

Should I use t or z?

Use t when the standard deviation was calculated from your sample. Use z only if the population standard deviation is genuinely known, or for proportions. For large samples the two are almost the same.

What is the margin of error?

Half the width of the interval: the critical value × the standard error. A poll's ±3% is a margin of error.

Why use the Wilson interval for proportions?

It stays reliable for small samples and for proportions near 0% or 100%, where the simpler Wald interval can be far too narrow or even go below 0.

Does a bigger sample make the interval narrower?

Yes. The width shrinks with √n, so 4 times the sample size halves the margin of error. The sample size calculator works this out in reverse.

Related calculators