Basic statistics

Margin of Error Calculator for Surveys and Polls (and Sample Size for a Target Margin)

Find the ± margin of error for a survey or poll result from the sample size, the percentage and the confidence level, or work backwards to the sample size you need for a target margin. Optional finite population correction for small populations such as one university or one district. Nothing is saved.

✅ No login needed100% freeRuns in your browserNothing savedYour data stays on your device
Margin of Error Calculator✅ Free · no login📚 Cite this tool
Your data never leaves your PC. Everything you type is calculated on your own computer or phone. Nothing is saved, not even in your browser, and it is gone when you close the page. Nothing is uploaded, stored or seen by Codanics, and no login is needed.
  • PriceFree, no login or sign-up needed
  • Your dataCalculated in your browser; nothing is saved
  • Works onPhone, tablet or computer, any modern browser
  • Made byDr. Muhammad Aammar Tufail, Codanics
  • Published24 November 2026
  • Last updated24 November 2026

📚 How to cite this tool

This tool is free. If it helped your thesis, paper, report or assignment, please cite it. It keeps the tools free and helps other students find them.

Citation · APA 7th edition

Tufail, M. A. (2026). Margin of error calculator [Online tool]. Codanics. Retrieved 24 November 2026, from https://codanics.com/tools/margin-of-error-calculator/

In-text citation: (Tufail, 2026) · Narrative: Tufail (2026)

The access date is today’s date, filled in automatically. Author: Muhammad Aammar Tufail. Published 24 November 2026.

🚀 Follow Codanics channel on WhatsApp for more updatesNew free tools, scholarships, PhD positions and research tips, straight to your phone. Free lessons on YouTube too.

How to use the margin of error calculator

  1. Pick Margin of error if you already have survey results, or Sample size for a margin if you are planning a survey.
  2. Enter the sample size (or target margin), the percentage (use 50% if you do not know it) and the confidence level.
  3. If you are surveying a small, known population (for example 2,000 students in one college), enter it as N for the finite population correction.
  4. Read the margin or the sample size with the full working, and copy it into your report or thesis.

What is the margin of error?

The margin of error is the “±” range around a survey result that shows how far the true population value could reasonably be from your sample estimate. If a poll of 1,000 voters finds 50% support with a ±3.1% margin at 95% confidence, the true support is likely between 46.9% and 53.1%.

It only covers random sampling error. It does not fix a biased sample, leading questions or low response rates.

Margin of error formula

E = z × √(p(1 − p) ÷ n) With a finite population: E = z × √(p(1 − p) ÷ n) × √((N − n) ÷ (N − 1)) Sample size: n₀ = z² × p(1 − p) ÷ E², n = n₀ ÷ (1 + (n₀ − 1) ÷ N)
ConfidencezMargin at n = 1,000, p = 50%
90%1.645±2.60%
95%1.960±3.10%
99%2.576±4.07%

Worked example

You survey 1,000 people in Lahore and 50% say yes. At 95% confidence:

  1. SE = √(0.5 × 0.5 ÷ 1,000) = 0.01581.
  2. E = 1.96 × 0.01581 = 0.0310, or ±3.1%.
  3. 95% CI = 46.9% to 53.1%.

Planning instead? For ±5% at 95% confidence and p = 50%: n₀ = 1.96² × 0.25 ÷ 0.05² = 384.1, so you need 385 responses. That is why “385” appears in so many theses from Pakistan and India. If your whole population is only 2,000 students, n = 384.1 ÷ (1 + 383.1 ÷ 2,000) = 322.4, so 323 is enough.

Tips

  • Use p = 50% when you do not know the answer in advance. It gives the largest, safest margin.
  • Quadruple n to halve the margin. Going from ±5% to ±2.5% needs about 4 times the sample.
  • Subgroups have bigger margins. If only 200 of your 1,000 respondents are women, the margin for women alone is about ±6.9%.
  • Allow for non-response. Invite more people than you need: if half respond, invite twice as many.
For a mean instead of a percentage, or for comparing groups, use the sample size calculator. To get the SE and CI for your finished data, use the standard error calculator.
Learn the statistics behind these numbers. Codanics has free statistics, R and Python lessons on YouTube and full courses for researchers.

Frequently asked questions

How do you calculate the margin of error?

Multiply the z value for your confidence level by the standard error: E = z × √(p(1 − p) ÷ n). For n = 1,000, p = 50% and 95% confidence, E = 1.96 × 0.0158 = ±3.1%.

What sample size gives a 5% margin of error?

About 385 responses for a large population at 95% confidence and p = 50%. For a small population, apply the finite population correction; for 2,000 people you need about 323.

What is a good margin of error for a survey?

Many academic surveys and opinion polls aim for ±5% or less at 95% confidence. National polls often target ±3%. The right value depends on how precise your decision needs to be.

Why use 50% when I don't know the percentage?

p(1 − p) is largest at p = 0.5, so 50% gives the biggest margin and the largest sample size. It is the safe, conservative choice.

When should I use the finite population correction?

When your sample is more than about 5% of the whole population, for example 400 out of 3,000 employees. It reduces the margin and the sample size needed.

Is my survey data saved?

No. The calculator runs entirely in your browser. Nothing is saved or uploaded.

Do I need to log in or create an account to use the margin of error calculator?

No. There is no login, no sign-up and no email required. Open the page and start using it straight away, for free, on any device.

How do I cite this tool in my thesis or paper?

Use the citation box on this page. In APA 7th edition: Tufail, M. A. (2026). Margin of error calculator [Online tool]. Codanics. Retrieved [date you used it], from https://codanics.com/tools/margin-of-error-calculator/. BibTeX, RIS (EndNote, Mendeley, Zotero), MLA, Harvard, Chicago and Vancouver formats are also available.

Free guides and courses from Codanics

More free tools

See all free Codanics tools → · Codanics on YouTube · WhatsApp channel

Made by Dr. Muhammad Aammar Tufail, Codanics. First published 24 November 2026, last updated 24 November 2026. Found a bug or have an idea for a new tool? Tell us on the WhatsApp channel or in the comments on YouTube. Results are for learning and planning; check important analyses with a statistician or your supervisor.