Work out how many people to survey, or how many items to measure, to hit the margin of error you want at your chosen confidence level.
How sample size is calculated
For a proportion, such as the percent of customers who say yes:
n₀ = z² × p(1 − p) ÷ E²
With a population of N: n = n₀ ÷ (1 + (n₀ − 1) ÷ N)
For a mean, when you have an estimate σ of the standard deviation:
n = (z × σ ÷ E)²
Here z is the critical value for your confidence level (1.96 for 95%) and E is the margin of error. Always round up to the next whole number.
Worked example
At 95% confidence with a ±5% margin and p = 50%: n₀ = 1.96² × 0.5 × 0.5 ÷ 0.05² = 384.1, so survey 385 people. If the whole population is only 1,000 people, the correction gives 384.1 ÷ (1 + 383.1 ÷ 1,000) = 277.7, so 278 is enough.
To estimate an average test score within ±5 points when scores have a standard deviation of about 15: (1.96 × 15 ÷ 5)² = 34.6, so measure 35.
Why 50%?
p(1 − p) is largest at p = 50%, so it gives the biggest, safest sample size. If an earlier survey suggests a proportion near 10% or 90%, using it lowers the sample size you need.
Limits
- These formulas assume a simple random sample. Cluster or stratified designs need a design-effect adjustment.
- The sample size is the number of completed responses. If you expect 20% to reply, invite 5 times as many.
- The finite population correction here is Cochran's version, n₀ ÷ (1 + (n₀ − 1) ÷ N). Some tools use n₀ ÷ (1 + n₀ ÷ N), which can differ by one.
- For a mean with a small sample, a t-based answer is a few units larger. Round up generously.
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:
- p written as 0.5 means 50%: 385, not 8 ✓
- margin written as 0.05 means 5%: 385 ✓
- 95%, ±5%, p = 50%: 385 ✓
- Same with a population of 1,000: 278 ✓
- 99%, ±2%, p = 20%: 2,654 ✓
- Mean, σ = 15, ±5 at 95%: 35 ✓
- A 0% margin of error is rejected ✓
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.
Questions people ask
How many people do I need to survey?
For a large population at 95% confidence and ±5%, you need 385 responses. For ±3% you need 1,068.
Does population size matter?
Only when the sample would be a sizable share of the population, roughly 5% or more. A survey of a whole country and a survey of one big city need about the same sample.
What margin of error should I use?
±5% is common for general surveys and ±3% for polls. Halving the margin of error roughly quadruples the sample size.
What if I don't know the standard deviation?
Use one from a pilot study or past data, or estimate it as the expected range ÷ 4.
Why round up instead of to the nearest number?
Rounding down would give a margin of error slightly larger than you asked for.