Sample size calculator

Find out how many survey responses or measurements you need for a given confidence level and margin of error, with the math shown step by step.

  • Free, no sign-up
  • Step-by-step working
  • Runs in your browser
What are you estimating?

Not sure? Use 50%, which gives the largest (safest) sample size.

How to use the sample size calculator

  1. Choose whether you're estimating a percentage (most surveys: "what share of customers…") or an average (for example mean spend or mean height).
  2. Pick a confidence level (95% is standard) and the margin of error you can accept, such as ±5%.
  3. For a percentage, enter your best guess of the result, or leave it at 50%. For an average, enter an estimate of the standard deviation.
  4. Optionally add the population size if it's small (a few thousand or fewer), and your expected response rate to see how many people to invite.
  5. Click Calculate sample size and read the result, the working and the chart of how sample size changes with the margin of error.

The sample size formula

For estimating a proportion (percentage), the sample size for a very large population is:

n0 = z2 · p(1 − p)E2

For estimating a mean, it is:

n0 = (z · σE)2

When the population is small, apply the finite population correction, then round up to a whole number:

n = n01 + n0 − 1N

z
The z-value for your confidence level: 1.645 for 90%, 1.960 for 95%, 2.576 for 99%
p
The expected proportion, as a decimal (0.5 if unknown)
σ
The estimated standard deviation of the measurement (for a mean)
E
The margin of error: as a decimal for a proportion (0.05 for ±5%), or in measurement units for a mean
n0, n
Sample size before and after the finite population correction
N
The population size

Worked example

A town of 20,000 residents wants to know what share support a new park. It wants ±4% precision at 95% confidence and has no earlier estimate, so it uses p = 0.5.

  1. Sample size for a large population
    n0 = 1.962 × 0.5 × 0.50.042 = 0.96040.0016 = 600.25
  2. Apply the finite population correction for N = 20,000
    n = 600.251 + 599.2520,000 = 600.251.0300 = 582.79
  3. Round up
    n = 583

What it means: the town needs 583 completed responses. If it expects 25% of residents to reply to a mailed survey, it should send about 583 ÷ 0.25 = 2,332 invitations.

How to interpret your sample size

The result is the number of completed responses you need, not the number of people you contact. If you collect that many from a random sample, then 95 times out of 100 (at 95% confidence) your result will be within the margin of error of the true population value.

A few things to keep in mind:

  • Precision is expensive. Cutting the margin of error in half needs about four times as many responses.
  • Subgroups need their own sample. If you plan to compare, say, men and women separately, each group needs enough responses for the precision you want.
  • Random beats big. A large sample of self-selected volunteers can be more misleading than a small random one. The formula assumes a random sample.
  • Plan for nonresponse. Use the response rate field to see how many people to invite.

Already collected your data? Use the p-value calculator to test your results, or the NPS calculator to see the margin of error for a Net Promoter Score.

Frequently asked questions

Why use 50% as the expected proportion?

The term p(1 − p) is largest when p = 50%, so 50% gives the biggest, most cautious sample size. If you have a reliable estimate from a previous survey or pilot study (say, 20% of customers use a feature), entering it gives a smaller sample size. If you are unsure, leave it at 50%.

What margin of error should I choose?

Many surveys and opinion polls use ±5% at 95% confidence. Use ±3% when precision really matters, such as for headline results, and ±10% only for rough, early-stage feedback. Halving the margin of error roughly quadruples the sample size, so precision gets expensive quickly.

Does population size matter?

Much less than most people expect. For large populations, the sample size barely changes: you need about 385 responses for ±5% at 95% confidence whether the population is 100,000 or 300 million. Population size matters only when your sample would be a sizable fraction of it, which is when the finite population correction kicks in.

What confidence level should I use?

95% is the standard choice in most research and business surveys. Use 99% when the cost of being wrong is high, and 90% for quick, exploratory work. A higher confidence level needs a larger sample for the same margin of error.

What if I can’t get enough responses?

You can still analyze the data, but your margin of error will be wider than planned. Enter the number of responses you can realistically get and adjust the margin of error until the sample size matches, or simply report the larger margin with your results. Also think about who didn’t respond, because nonresponse bias can matter more than sample size.

How do I calculate sample size for a mean instead of a percentage?

Choose "Average (mean)" at the top of the calculator. You will need an estimate of the standard deviation, from a pilot study, previous research or a rough guess (range ÷ 4). The formula becomes n = (z × σ ÷ E)², where E is the margin of error in the same units as your measurement.

Last reviewed November 10, 2026