Chi-square test calculator

Paste a table of counts to test whether two categories are related, or test whether counts fit what you expected, with every step shown.

  • Free, no sign-up
  • Step-by-step working
  • Runs in your browser
  1. 1 Copy and paste your data
  2. 2 Choose an option
  3. 3 Click “Run test”
  4. 4 Read the result
How to use the Chi-square test calculator: 1. Copy and paste your data (copy the cells in Excel or Google Sheets, then paste them into the box). 2. Choose an option (Independence). 3. Click “Run test”. 4. Read the result (χ² = 17.32, df = 4: p = 0.0017).

Tip: No need to type: copy your numbers from Excel, Google Sheets or a CSV file and paste them straight into the box.

This is example data so you can see how the tool works. Replace it with your own: copy your numbers from Excel or Google Sheets and paste them in, or type them.

Step 1: Choose your test

Which test?

Step 2: Paste or type your counts

Paste the table straight from a spreadsheet, headings included, or type one row per line: 30, 45, 25

Step 3: Options (the defaults suit most tests)

Step 4: Your result

How to use the chi-square test calculator

  1. Choose the test of independence for a table of counts (two categorical variables), or goodness of fit for one list of counts.
  2. Copy your table from Excel or Google Sheets, headings included, and paste it in. For goodness of fit, paste the categories and their counts, and pick equal or your own expected values.
  3. Keep the significance level at 0.05 unless your course says otherwise, then click Run chi-square test.
  4. Read χ², the degrees of freedom and the p-value, then the plain-English summary of which cells differ most from what was expected.
  5. Check the warning about small expected counts, and download the chart if you need it.

Chi-square test formula

Both tests compare the observed counts with the counts you would expect if the null hypothesis were true:

χ2 = Σ (O − E)2E

For a test of independence, each cell's expected count comes from its row and column totals:

E = row total × column totalgrand total , df = (r − 1)(c − 1)

For goodness of fit, the expected count is the total times the expected proportion, and df = k − 1.

O
The observed count in a cell or category
E
The expected count if the null hypothesis is true (no association, or the expected distribution)
χ2
The test statistic: the bigger it is, the further the data are from what was expected
df
Degrees of freedom: (rows − 1) × (columns − 1) for a table, or categories − 1 for goodness of fit
r, c, k
The number of rows, columns, and categories

Worked example

You roll a die 60 times and get 8 ones, 12 twos, 9 threes, 11 fours, 6 fives and 14 sixes. Is the die fair?

  1. If the die is fair, each face is expected 60 ÷ 6 times
    E = 10
  2. Add up (O − E)² ÷ E for the six faces
    χ2 = (8 − 10)² + (12 − 10)² + (9 − 10)² + (11 − 10)² + (6 − 10)² + (14 − 10)²10 = 4210 = 4.2
  3. Degrees of freedom and p-value
    df = 6 − 1 = 5, p = P(χ2 ≥ 4.2) = 0.521

What it means: p = 0.521 is far above 0.05, so there's no evidence the die is unfair. Rolls of 6 and 14 look uneven, but differences that size happen by chance in 60 rolls more than half the time. You can check χ² against the cutoff in the chi-square table: with 5 df at α = 0.05 it's 11.070, and 4.2 is well below it.

How to interpret the result

  • p ≤ α (significant): for independence, the two variables are related; the pattern in the table is unlikely to be chance. For goodness of fit, the counts don't match the expected distribution.
  • p > α (not significant): the data are consistent with no association, or with the expected distribution. That isn't proof they're equal, only a lack of evidence against it.
  • Where the difference is: look at the cells with the largest contributions, (O − E)² ÷ E. The calculator names them and says whether each count is higher or lower than expected.
  • How strong: for a table, Cramér's V gives the size of the association, which a p-value alone doesn't.
  • Check the expected counts: if any are below 5, the p-value may not be accurate.

Already have a χ² value and just need its p-value? Use the p-value calculator. To chart the counts, paste them into the bar graph maker.

Frequently asked questions

Which chi-square test should I use?

Use the test of independence when you have two categorical variables measured on the same people or things, arranged in a table: for example school year and preferred study method. It asks whether the two are related. Use the goodness-of-fit test when you have one categorical variable and want to compare its counts with expected ones: for example whether a die is fair, or whether customers are spread across regions the way the population is.

What does “expected counts of at least 5” mean?

The chi-square test is an approximation that works well only when the expected count in each cell is large enough. The usual rule is that every expected count should be at least 5 (some books allow up to 20% of cells between 1 and 5, but none below 1). If yours are smaller, combine categories that make sense together, collect more data, or for a 2×2 table use Fisher’s exact test. The calculator warns you when the rule is broken.

What is Yates’ continuity correction?

For a 2×2 table, Yates’ correction subtracts 0.5 from each |O − E| before squaring, which makes the test more conservative (a smaller χ² and a larger p-value). It used to be standard for small samples, but many statisticians now consider it too cautious. Use it if your course or software (such as R’s default chisq.test) uses it.

What is Cramér’s V?

Cramér’s V measures the strength of the association in a test of independence, from 0 (none) to 1 (perfect). The p-value only says whether an association is likely to be real; with a big sample, even a weak association is significant. As a rough guide, V around 0.1 is small, 0.3 medium and 0.5 large (for tables with a smaller dimension of 2; the cutoffs are lower for bigger tables).

Can I use percentages instead of counts?

Not for the observed data. The test needs the actual counts, because 50% of 10 people is much less certain than 50% of 1,000. Expected values in a goodness-of-fit test can be given as percentages or proportions; the calculator scales them to your total.

How do I do a chi-square test in Excel or Google Sheets?

Excel’s =CHISQ.TEST(actual_range, expected_range) returns only the p-value, and you have to build the table of expected counts yourself first (row total × column total ÷ grand total for each cell). To get χ² itself, use =CHISQ.INV.RT(p, df). This calculator does all of it from the pasted table and shows the working.

Last reviewed November 13, 2026