Chi-Square Test Calculator: Independence, Goodness of Fit and Fisher's Exact Test
Test whether two categorical variables are related, such as gender and preferred treatment or variety and disease status, or whether observed counts match what you expected. Edit the table, and the results update as you type.
| Category | Observed | Expected % (optional) |
|---|
Leave the expected % empty to test against equal proportions. If you fill them in, they should add up to 100.
How to use the chi-square calculator
- For two categorical variables, stay on Test of independence. Choose the number of rows and columns and rename the labels.
- Type the counts (frequencies, not percentages) into the cells, or use Paste from Excel or Upload CSV / Excel. You can load a table of counts, or raw data with one row per person, which is cross-tabulated for you. Results update as you type.
- Check the expected counts. If many are below 5 in a 2×2 table, report Fisher’s exact test, which is calculated for you.
- For one variable compared with known or equal proportions, use the Goodness of fit tab.
- Copy the APA sentence and look at the residuals to see which cells drive the association.
When to use a chi-square test
Use the chi-square test of independence when both variables are categorical and each person or sample is counted once, for example smoker or non-smoker against lung disease yes or no. Use the goodness-of-fit test when you have one categorical variable and want to compare it with a theoretical distribution, such as a 9:3:3:1 Mendelian ratio or equal preference for four brands.
Formulas
Assumptions
- The data are counts, not percentages or means.
- Each observation falls in exactly one cell, and observations are independent. For before-and-after yes/no data, use McNemar’s test instead.
- No more than 20% of expected counts are below 5, and none is below 1.
Frequently asked questions
Can I enter percentages in a chi-square test?
No. The chi-square test needs raw counts. If you only have percentages, multiply them by the group size to get counts first.
When should I use Fisher's exact test instead of chi-square?
Use Fisher’s exact test for a 2×2 table when any expected count is below 5, which usually happens with small samples. This calculator shows Fisher’s p automatically for every 2×2 table.
Should I use Yates' continuity correction?
Yates’ correction makes the 2×2 chi-square more conservative. Many statisticians now prefer to report the uncorrected chi-square for large samples and Fisher’s exact test for small ones. If your supervisor or journal asks for Yates, tick the box.
How do I report a chi-square test in APA format?
Write χ²(df, N = total) = value, p = value, followed by an effect size, for example: χ²(1, N = 80) = 11.43, p < .001, φ = .38.
What do the standardized residuals mean?
They show which cells contribute most to a significant result. A residual above +1.96 means more observations than expected, and below −1.96 means fewer, at roughly the 5% level.
Is my data private?
Yes. All calculations happen in your browser.