Sample size calculator for surveys and A/B tests
This sample size calculator answers the question that comes before every survey and experiment: how many people do I need? It has two modes. Survey mode gives the number of completed responses for a chosen margin of error and confidence level, with an optional correction for a small population. A/B test mode gives the visitors needed in each version to detect a change in a conversion rate with a chosen confidence and power.
Both use standard textbook formulas, shown under the result, and run in your browser. It suits market researchers, students, marketers planning a landing-page test and anyone who has been asked to justify a sample.
How to use the Sample Size Calculator
- Choose Survey or A/B test.
- For a survey, set the confidence level and margin of error. Keep the expected proportion at 50% unless you have a good reason to change it. Add the population size if it is small, and an expected response rate to see how many people to invite.
- For an A/B test, enter the baseline conversion rate and the smallest improvement worth detecting, as a relative or absolute change. Pick confidence, power and one- or two-sided.
- Optionally add your daily visitors to see how many days the test needs.
- Read the headline number and the supporting figures underneath.
Sample Size Calculator features
Finite population correction
Small populations need fewer responses; the survey mode applies the standard correction.
Invitations from response rate
Turns completed responses into the number of people to contact.
Power analysis for two proportions
Per-version and total visitors from baseline, effect size, confidence and power.
Relative or absolute effect
Enter the improvement as 20% of baseline or as 1 percentage point; both are converted for you.
Survey sample size formula (Cochran)
For a very large population the required sample is n = z² × p(1 − p) ÷ e², where z is the normal score for the confidence level (1.96 for 95%), p the expected proportion and e the margin of error as a decimal. With p = 0.5 and e = 0.05 that is 1.96² × 0.25 ÷ 0.0025 = 384.16, so 385 responses.
For a finite population N the result is reduced to n ÷ (1 + (n − 1) ÷ N). For N = 1,000 that gives 278, which matches the widely used Krejcie and Morgan (1970) table. The correction matters little once the population is many times larger than the sample.
| Population | Responses (95%, ±5%) |
|---|---|
| 100 | 80 |
| 1,000 | 278 |
| 10,000 | 370 |
| Very large | 385 |
A/B test sample size and the peeking problem
The A/B formula for two proportions is n = [zα/2·√(2p̄q̄) + zβ·√(p₁q₁ + p₂q₂)]² ÷ (p₂ − p₁)², with p̄ the average of the two rates. Moving from 20% to 30% at 95% confidence and 80% power needs 294 visitors per version. Moving from 5% to 6% needs about 8,100, because small effects on small rates need much larger samples.
Fix the sample size before the test starts. If you look at the results every day and stop the moment they look significant, the real false-positive rate is far higher than 5%. When you compare more than two versions this tool divides the significance level by the number of comparisons (a Bonferroni adjustment), which is cautious but simple. When the test ends, check the outcome with the A/B test significance calculator.
Limits
- The formulas assume random sampling and independent responses. They do not fix a biased sample, low response from one group or poorly worded questions.
- The margin of error applies to the whole sample; results for small subgroups, such as one region, are less precise.
- The A/B formula uses a normal approximation, which is reliable when expected conversions per version are well above 5 to 10.
- To judge a survey of customer sentiment, see the net promoter score calculator.
Sample Size Calculator FAQ
How do you calculate sample size?
For a survey use n = z² p(1 − p) ÷ e². At 95% confidence, ±5% and p = 50% that is 385 responses. Enter the same values here to check it.
What does 50% expected proportion mean?
It is the value of p that gives the largest sample, so it is the safe choice when you do not know what answer to expect. If you are sure that only about 10% will answer yes, a smaller sample is enough.
Is a sample of 385 enough for any population?
For 95% confidence and a ±5% margin of error, 385 is the figure for a very large population. Small populations need fewer, and a tighter margin or higher confidence needs more.
What is the minimum detectable effect?
The smallest change in your metric that you want the test to be able to detect. A smaller effect needs a much larger sample, so choose the smallest change that would actually matter to your business.
What is statistical power?
The chance the test will detect a real effect of the size you entered. 80% power means a 20% risk of missing it. Higher power needs more visitors.
Should I use a one-sided or two-sided test?
Two-sided is the default because it also catches a version that is worse. One-sided needs fewer visitors but ignores that possibility, so use it only if you will act on a loss in the same way as no change.