01
How to use the chi-square calculator
- Set the number of rows (groups) and columns (outcomes) with the + and − buttons.
- Enter the number of observations in each cell, or paste a block of cells copied from a spreadsheet into any box. Use raw counts, not percentages.
- Read the result: it updates as soon as every cell is filled.
- Check the expected counts. If any is below 5, follow the warning.
02
The chi-square formula
expected = row total × column total ÷ grand total
χ² = Σ (observed − expected)² ÷ expected
df = (rows − 1) × (columns − 1)
The expected count is what each cell would hold if group and outcome were unrelated. The further the observed counts are from those, the larger χ² and the smaller the p value.
03
Worked example
The calculator opens with this 2 × 2 table:
| Outcome 1 | Outcome 2 | Total | |
|---|---|---|---|
| Group 1 | 10 (expected 12) | 20 (expected 18) | 30 |
| Group 2 | 30 (expected 28) | 40 (expected 42) | 70 |
| Total | 40 | 60 | 100 |
χ² = 4/12 + 4/18 + 4/28 + 4/42 = 0.794, df = 1, p = .373
The proportions with outcome 1 (33% and 43%) do not differ significantly. Reported as: χ²(1, N = 100) = 0.79, p = .373.
04
When the chi-square test is valid
- Counts, not measurements. Every cell is a number of observations.
- Independent observations. Each subject is counted once. Before-and-after data on the same subjects need McNemar’s test.
- Yates’ correction for 2 × 2 tables. For a 2 × 2 table the calculator also shows the continuity-corrected statistic, Σ(|O − E| − 0.5)² ÷ E, which is more cautious with small samples: 0.446 (p = .504) in the example, against 0.794 (p = .373) uncorrected. Say which one you report.
- Expected counts of about 5 or more. The p value comes from an approximation that breaks down with sparse tables. For a 2 × 2 table with small counts use the Fisher’s exact test calculator; for a larger table, merge small categories.
05
Cramér’s V: the size of the association
V = √( χ² ÷ (N × (smaller of rows, columns − 1)) )
V runs from 0 (no association) to 1 (perfect association) and does not grow just because the sample is large, unlike χ² itself. For a 2 × 2 table it equals the phi coefficient. Report it next to the p value.
06
Already have a chi-square value?
If a paper or your software gives you χ² and its degrees of freedom and you only need the p value, use the p value calculator.
07
Common mistakes with the chi-square test
- Entering percentages. Typing the example’s row percentages (33 and 67, 43 and 57) as if they were counts gives χ² = 2.12 and p = .145, as though 200 people had been studied instead of 100.
- Reading a small p as a strong association. Ten times the example’s counts gives χ² = 7.94 and p = .005, but Cramér’s V stays at 0.089 because the proportions have not changed.
- Ignoring small expected counts. In the table 5, 1 / 1, 5 every expected count is 3; the chi-square test gives p = .021, Fisher’s exact test p = .080.
- Choosing Yates’ correction after seeing the result. In the example the two versions give p = .373 and p = .504; decide before you look.
Trust
How this page is checked
- The calculation runs on code with automated tests against worked reference values. Every number in the examples on this page was produced by that same code, not typed by hand.
- The formulas and conventions used are stated on the page, so you can reproduce the result yourself or compare it with your own software.
- Last reviewed by the Sciloom team, Zebra Nine Studio Inc. It is a tool for research and teaching, not a substitute for a statistician, a validated lab method or medical advice.
Cite this page
Sciloom. (2026). Chi-square calculator. Zebra Nine Studio Inc. https://sciloom.si/chi-square-calculator
Frequently asked questions
What does a chi-square test tell you?
Whether the distribution of one categorical variable differs between the levels of another, for example whether recovery rates differ between treatments. A small p value means the two are associated.
How do I calculate degrees of freedom for chi-square?
Multiply the number of rows minus one by the number of columns minus one. A 2 × 2 table has 1 degree of freedom; a 3 × 4 table has 6.
Can I use percentages in a chi-square test?
No. The test needs the actual counts, because the same percentages from 20 people and from 2,000 people carry very different evidence.
What if an expected count is less than 5?
The chi-square approximation becomes unreliable. Use Fisher’s exact test for a 2 × 2 table, or combine categories in a larger table.