CalcThis CalcThis
Two-way table · goodness of fit · Fisher, Yates and McNemar

Chi Square Calculator

Type your counts into the table (or paste them, or paste the raw answers) and get χ², the p-value, the expected counts and a picture of where the difference comes from. For the example of two groups with three answers (20, 30, 50 and 30, 40, 30) the result is χ² = 8.4286, 2 degrees of freedom, p = 0.01478.

Your counts

What do you want to test?

How will you enter the table?
Counts names are optional

Try an example

Chi-square test of independence
—
Type your counts to see χ², the p-value, the expected counts and a picture of where the difference comes from.
Chi-square
—

How to use the chi square calculator

Pick Two-way table to ask whether two things are related, or Goodness of fit to ask whether one list of counts matches what you expect. Type a count in each box (add rows and columns as needed), paste a table from a spreadsheet, or paste one line of raw answers per person and the table builds itself. The result updates as you type.

Under Go advanced you can name the variables, choose the headline test for a 2×2 table, allow for parameters estimated from the data, plan for an effect size and set the decimal places.

The chi square formula

χ² = Σ (O − E)² ÷ E O = observed count · E = expected count · TABLE: E = row total × column total ÷ grand total, df = (rows − 1) × (columns − 1) · LIST: E = total × expected share, df = categories − 1

Worked example: two groups, three answers

BoxObservedExpected(O − E)² ÷ E
A low20251.0000
A medium30350.7143
A high50402.5000
B low30251.0000
B medium40350.7143
B high30402.5000

The contributions add up to χ² = 8.4286 with 2 degrees of freedom. The p-value is 0.01478 and the critical value at 0.05 is 5.9915. Cramér’s V is 0.2053. The two outer columns carry almost all of the difference; the middle one adds 1.4286.

Goodness of fit examples

A die rolled 60 times shows 8, 12, 9, 14, 11 and 6. Each face is expected 10 times, so χ² = 4.2000 with 5 degrees of freedom and p = 0.521: nothing unusual for a fair die.

Counts of 315, 108, 101 and 32 tested against a 9:3:3:1 ratio give χ² = 0.4700 with 3 degrees of freedom and p = 0.9254, a very close fit. A coin showing 62 heads in 100 tosses gives χ² = 5.7600 and p = 0.0164; the exact binomial test gives 0.02098.

Chi-square critical values

A statistic above the value in the table is significant at that level. For other degrees of freedom or levels, choose “χ² value” and type only the degrees of freedom.

df0.100.050.010.001
12.7063.8416.63510.828
24.6055.9919.21013.816
36.2517.81511.34516.266
47.7799.48813.27718.467
59.23611.07015.08620.515
610.64512.59216.81222.458
712.01714.06718.47524.322
813.36215.50720.09026.124
914.68416.91921.66627.877
1015.98718.30723.20929.588
1218.54921.02626.21732.909
1522.30724.99630.57837.697
2028.41231.41037.56645.315
2534.38237.65244.31452.620
3040.25643.77350.89259.703

Where the difference comes from

One χ² number does not say which counts are unusual. The picture on this page does: each row of the table becomes a bar split into its columns, with dashed lines showing where the pieces would end if nothing differed. Amber pieces hold more counts than expected and blue pieces fewer, with stronger colour further from expected. The cell table gives each box its contribution and its standardized difference; beyond ±2 is unusual.

Small counts: Fisher, Yates and merging

The chi-square p-value is an approximation. A common rule asks for expected counts of at least 5 in every box of a 2×2 table, and in at least 80% of the boxes of a bigger one with none below 1. For the 2×2 table 20, 10 and 30, 40 the three p-values are 0.0291 (Pearson), 0.04953 (Yates) and 0.04858 (Fisher, two-sided). For 20, 30 and 30, 40 they are 0.7543, 0.9004 and 0.8515.

In a bigger table you can merge two rows, columns or categories on the page and undo it. Merge only groups that mean something together, and choose them before looking at which choice gives the p-value you like.

The same people twice: McNemar

If 314 patients are checked before and after a treatment and 101 are positive both times, 121 go from positive to negative, 59 from negative to positive and 33 are negative both times, only the 180 who changed are tested: χ² = (121 − 59)² ÷ 180 = 21.3556, p = 3.815 × 10⁻⁶. With fewer than 25 changes the exact or mid-p value is the better choice.

Effect size and sample size

Cohen’s w = √(χ² ÷ N) measures the size of a difference independently of the number of counts. In the worked example w = 0.2053; if the true shares were exactly those, a new study of 200 counts would reach p below 0.05 74.1% of the time and 229 counts would give 80% power. With 100 counts and 1 degree of freedom, a medium effect (w = 0.3) has 85.1% power.

dfw = 0.1w = 0.3w = 0.5
17858832
296410839
3109112244
4119413348
6136315255

Counts needed for 80% power at α = 0.05.

Related tools

To turn any statistic into a probability use the p-value calculator; to compare two averages the t-test calculator; for the uncertainty of a proportion the confidence interval calculator; and for two number variables the correlation coefficient calculator.

Sources

  • The statistic Σ(O − E)² ÷ E, the degrees of freedom (categories − 1 − estimated parameters, or (rows − 1) × (columns − 1)), the expected counts and the rule of 5 or more in all boxes of a 2×2 table and in 80% of the boxes of larger tables, with none at 0, follow the Wikipedia article “Pearson’s chi-squared test” (read 2026-11-25).
  • Yates’s correction of 0.5 follows “Yates’s correction for continuity”; here it never takes off more than the difference itself. Fisher’s two-sided p-value adds every table with the same totals whose probability is no larger than that of yours, as described in “Fisher’s exact test”. The exact test for two categories follows “Binomial test” (read 2026-11-26).
  • McNemar’s statistic, the corrected version, the exact and mid-p values and the guide of 25 changes follow “McNemar’s test”. Its first example (101, 121, 59, 33) gives 21.35 there and 21.3556 here; its second (59, 6, 16, 80) gives an exact p of 0.053 and a corrected χ² of 3.68, and this page gives 0.052 and 3.68 (read 2026-11-26).
  • The standardized difference of a box is the adjusted residual (O − E) ÷ √(E × (1 − row share) × (1 − column share)), with about ±2 unusual and ±3 very unusual, from the CASRAI guide “Standardized Residuals” (read 2026-11-25). For a single list the same idea uses (O − E) ÷ √(E × (1 − expected share)).
  • Cramér’s V and Cohen’s w (small 0.1, medium 0.3, large 0.5) follow “Cramér’s V” and “Effect size” (read 2026-11-25). Power uses the noncentral chi-square distribution with noncentrality N × w², as in the pingouin documentation of power_chi2, whose examples (power 0.2687 for w = 0.3, 20 counts, 1 degree of freedom; 121.14 counts for 3 degrees of freedom and 80% power) this calculator reproduces (read 2026-11-26).
  • The feature set was compared with the chi-square tools of Omnicalculator, Social Science Statistics, GraphPad QuickCalcs, Statistics by Jim, GigaCalculator, Pearson.com, MiniWebtool and Stats Kingdom, all opened on 2026-11-25.

For information only. Check the assumptions of the method and your own data before drawing conclusions.

Common questions

What is a chi-square test?

It compares counts you observed with the counts you would expect if there were nothing going on. The statistic χ² adds up (observed − expected)² ÷ expected over every box. The larger it is for its degrees of freedom, the smaller the p-value.

What is the difference between independence and goodness of fit?

Independence takes a two-way table, such as group by answer, and asks whether the two are related. Goodness of fit takes one list of counts, such as the faces of a die, and asks whether they match shares you state in advance.

How do I calculate expected counts?

In a table, expected = row total × column total ÷ grand total. In the example the first box is 100 × 50 ÷ 200 = 25. In a goodness-of-fit test, expected = total × expected share.

How many degrees of freedom are there?

For a table it is (rows − 1) × (columns − 1), so a 2×3 table has 2. For goodness of fit it is the number of categories − 1, less one for each parameter you estimated from the same data.

What p-value is significant?

The usual line is 0.05: a p-value below it counts as significant. You can type another level. The example has p = 0.01478, below 0.05, so the two rows split differently by more than chance usually produces.

Can I use percentages instead of counts?

No. The test depends on how many people or items there are: the same percentages from 20 and from 2,000 observations give very different results. Convert percentages back to counts first. Percentages are fine as expected shares in a goodness-of-fit test.

What if an expected count is below 5?

The chi-square p-value becomes unreliable when expected counts are small. For a 2×2 table use Fisher’s exact test, which this page shows next to it; for two categories use the exact binomial test; for bigger tables, merge groups that belong together or collect more data.

When should I use Fisher’s exact test or Yates’s correction?

Both apply to 2×2 tables. Fisher’s test is exact and suits small counts. Yates’s correction lowers χ² to allow for counts being whole numbers and is more cautious. For the table 20, 10 and 30, 40 the p-values are 0.0291 (Pearson), 0.04953 (Yates) and 0.04858 (Fisher, two-sided).

When do I need McNemar’s test?

Use it when the same people were measured twice with a yes or no answer, such as before and after. Only the people who changed enter the test: χ² = (b − c)² ÷ (b + c). Fill a 2×2 table and choose “Same people twice”.

Does a large χ² mean a strong effect?

No. χ² grows with the number of counts. Cramér’s V and Cohen’s w describe the size of the effect. In the example w = 0.2053, a small effect by Cohen’s guide.

How many observations do I need?

That depends on the effect you want to be able to detect. For 80% power at α = 0.05 with 1 degree of freedom you need about 785 counts for a small effect (w = 0.1), 88 for a medium one (0.3) and 32 for a large one (0.5).

I only have the χ² value. Can I get the p-value?

Yes. Choose “χ² value”, type the statistic and the degrees of freedom, and the p-value, the critical value and the curve appear. For example χ² = 3.84 with 1 degree of freedom gives p = 0.05004. With only the degrees of freedom typed, the critical value is shown.