Chi-square calculator

This chi-square calculator tests whether two categorical variables are related. Type your counts into the table, for example treatment group by outcome, and read the chi-square statistic, the p value, the expected counts and the effect size, with a warning when the test should not be trusted.

Your numbers are calculated in your browser. Nothing you enter is sent or stored.

Chi-square calculatorOr describe it in Studio →
Rows2Columns2
Outcome 1Outcome 2
Group 1
Group 2

You can paste a block of cells copied from a spreadsheet into any box. Enter counts (numbers of observations), not percentages or means. Each observation belongs to exactly one cell.

No significant association between group and outcome (p = .373).

Chi-square (χ²)
0.794
Degrees of freedom
1
p value
0.3730
With Yates’ correction
χ² = 0.446, p = 0.5040
Cramér’s V
0.089
Total (N)
100

Expected counts

Group 11218
Group 22842

To report

χ²(1, N = 100) = 0.79, p = .373, V = .09

Check your result: the expected counts keep your totals. Each row of expected counts adds up to the observed row total (12 + 18 = 30 in the example), and the contributions (O − E)² ÷ E add up to χ². Cramér’s V always lies between 0 and 1.
largest table
6 × 6
largest table
χ² in the worked example, p = .373
0.794
χ² in the worked example, p = .373
with Yates’ correction, p = .504
0.446
with Yates’ correction, p = .504
expected count below which a cell is flagged
5
expected count below which a cell is flagged
  • Tables from 2 × 2 to 6 × 6
  • χ², df, p and Cramér’s V
  • Expected counts shown
  • Warns when counts are too small
  • Runs in your browser, free

01

How to use the chi-square calculator

  1. Set the number of rows (groups) and columns (outcomes) with the + and − buttons.
  2. 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.
  3. Read the result: it updates as soon as every cell is filled.
  4. Check the expected counts. If any is below 5, follow the warning.
07.815145%test statistic
A right-tail p value. Statistics such as chi-square, F and H can only be zero or positive, and larger values mean a worse fit to the null hypothesis. The p value is the area to the right of your statistic. The curve shown has 3 degrees of freedom; 5% of its area lies beyond 7.815.

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 1Outcome 2Total
Group 110 (expected 12)20 (expected 18)30
Group 230 (expected 28)40 (expected 42)70
Total4060100

χ² = 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

Read the full methodology · Who makes Sciloom

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.

Comparing means rather than counts? Use the t-test calculator.
Free to start, no sign-up.
Back to the tool ↑

More research tools