In more detail
For a proportion, n = z² × p(1 − p) / e², where z is the critical value for the confidence level (1.96 for 95%), p the expected proportion and e the margin of error. Using p = 0.5 gives the largest, safest n when you have no prior estimate. Always round up. For a mean, replace p(1 − p) with the squared standard deviation. When the sample is a large share of a small population, the finite-population correction n / (1 + (n − 1) / N) reduces the requirement.
Why it matters
Too small a sample gives margins so wide that the result is meaningless; too large wastes money. Halving the margin of error needs four times the data, because the margin shrinks with √n. The formula counts completed responses: if only 20% of people reply, you must invite five times as many. A big sample does not fix a biased one.
Example
95%, p = 0.5, ±5% n = 1.96² × 0.25 / 0.05² = 384.16 → 385
99%, p = 0.5, ±5% n = 2.576² × 0.25 / 0.05² = 663.5 → 664
95%, p = 0.5, ±2.5% n = 384.16 × 4 = 1,536.6 → 1,537
population of 2,000 n = 384.16 / (1 + 383.16 / 2,000) = 322.4 → 323
With a 20% response rate, 385 replies need 1,925 invitations. A sample of 1,000 gives a margin of about ±3.1% at 95%.
Common confusion
The margin of error used here is half the width of the Confidence interval you will get, not the expected error of every individual answer.