How to use the sample size calculator
- Choose whether to find a sample size, before a survey or study, or the margin of error, after one.
- Choose what you are measuring: a percentage, such as the share of customers who would recommend you, or an average, such as the average time on a task.
- Enter the confidence level and the margin of error you want, or the number of responses you got. For a percentage, enter the share you expect, or leave it at 50%. For an average, enter the standard deviation you expect.
- If your whole population is small, such as the staff of one company, enter its size. If only some people will answer, enter the response rate to see how many to invite.
The answer, the steps and a table of other margins and confidence levels update as you type.
The sample size formula
For a percentage, the sample size for a large population is
n₀ = z² × p(1 − p) / E²
where z is the z-score for the confidence level, p is the expected proportion and E is the margin of error, both as decimals. At 95% confidence, z = 1.959964, usually rounded to 1.96. With p = 0.5 and a margin of 5%, n₀ = 1.959964² × 0.5 × 0.5 / 0.05² = 384.15. The answer is always rounded up, to 385, because a sample of 384 would leave the margin a little over 5%. OpenStax’s Introductory Statistics (section 8.3) gives the same formula and the same instruction: “round the answer to the next higher value”. Its example, 90% confidence and a margin of 3 percentage points, needs 752 people.
For an average, the formula uses the standard deviation σ in place of p(1 − p): n₀ = (z × σ / E)². To estimate an average within ±2 when the values have a standard deviation of about 15, at 95%, you need (1.96 × 15 / 2)² = 216.1, so 217.
Choosing the confidence level
The confidence level is how sure you want to be that the true figure lies within your margin of error. At 95%, if you ran the same survey many times, about 95 in 100 of the ranges it gives, the result plus or minus the margin, would contain the true value. Higher confidence needs more responses. For a ±5% margin with no idea of the answer, you need 271 at 90%, 385 at 95% and 664 at 99%. 95% is the usual choice; this calculator works out the exact z-score for any level, such as 97.5% or 99.9%, rather than only a few fixed ones.
Choosing the margin of error
The margin of error is how far your result may be from the truth. A survey that finds 62% with a ±5% margin is saying the true figure is probably between 57% and 67%. Smaller margins cost a lot more: the sample size grows with the square of 1 / E, so halving the margin needs four times as many responses. At 95% confidence, ±5% needs 385, ±3% needs 1,068, ±2% needs 2,401 and ±1% needs 9,604.
Why 50% is the safe guess
The product p(1 − p) is largest when p is 0.5, where it is 0.25. Any other value gives a smaller product and so a smaller sample. If you expect about 20% of people to say yes, the sample for ±5% at 95% falls to 246. But if your guess is wrong and the true figure is nearer 50%, that smaller sample won’t meet the margin. When you have no figure from an earlier survey or a pilot study, 50% is the safe choice.
Small populations
For a large population, its size hardly matters: a sample of 385 gives about ±5% for a city or a whole country alike, and 384 is enough for a city of a million. When the population is small, each response is a bigger share of the group, and fewer are needed. The calculator applies the finite population correction, n = n₀ / (1 + (n₀ − 1) / N), where N is the population size. For a company of 500 people, ±5% at 95% needs 218, not 385. This is the exact reverse of the margin-of-error formula with the correction factor √((N − n) / (N − 1)), so the two modes of this calculator always agree: the sample size it gives is the smallest that meets your margin.
Allowing for people who don’t answer
The sample size is the number of responses you need, not the number of people to ask. If you expect 30% of the people you invite to answer, divide by 0.3: for 385 responses, invite 1,284. Enter your expected response rate and the calculator does this for you, rounding up.
Margin of error from a finished survey
Choose “Margin of error” to work backwards from the number of responses you got. The formula is E = z × √(p(1 − p) / n). With 1,000 responses at 95% confidence, the margin is about ±3.1%; with 400, about ±4.9%. If you enter the percentage your survey found, the calculator also shows the range the true figure probably lies in.
What the margin of error doesn’t cover
These formulas assume a random sample, where everyone in the population had the same chance of being picked. They measure only the error from surveying some people rather than all of them. They don’t cover people who chose not to answer and may think differently, leading questions, or a list of people that misses part of the population. A large sample can’t fix a biased one. And if you plan to report results for smaller groups, such as each age band, each group needs enough responses on its own.
Your data stays on your device
Everything is worked out in your browser. Nothing you type is sent anywhere or stored.
Frequently asked questions
What sample size do I need for a 95% confidence level and a 5% margin of error?
385 responses, for a large population, when you have no idea what the answer will be (so you assume 50%). The formula gives 384.15, and a sample size is always rounded up, so the margin is met. For a smaller population you need fewer: 218 for a population of 500.
Why do some calculators say 384 and others 385?
Both start from 1.96² × 0.5 × 0.5 / 0.05² = 384.16. Rounding that down to 384 leaves the margin of error just over 5%. Rounding up to 385 meets it. This calculator always rounds up and uses the exact z-score, 1.959964.
Does the population size matter?
Only when the population is small. For a city of a million people you need 384 for ±5% at 95%, almost the same as for the whole country. For a company of 500 you need 218, because each person surveyed is a bigger share of the group.
What is a good margin of error?
For most surveys, ±5% at 95% confidence is the common choice. A smaller margin needs a much bigger sample: halving the margin needs four times as many responses.
What should I put for the expected percentage?
If you have a figure from an earlier survey or a pilot study, use it. If not, use 50%: it gives the largest, safest sample size, so the margin is met whatever the answer turns out to be.
Is anything I type saved or sent?
No. Everything is worked out in your browser and nothing you type is sent anywhere or stored.