Statistics

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.

100% freeNo sign-upRuns in your browser
Chi-Square Calculator🔒 Your data never leaves your device

How to use the chi-square calculator

  1. For two categorical variables, stay on Test of independence. Choose the number of rows and columns and rename the labels.
  2. 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.
  3. Check the expected counts. If many are below 5 in a 2×2 table, report Fisher’s exact test, which is calculated for you.
  4. For one variable compared with known or equal proportions, use the Goodness of fit tab.
  5. 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

Expected count Eᵢⱼ = (row totalᵢ × column totalⱼ) / N Chi-square χ² = Σ (Oᵢⱼ − Eᵢⱼ)² / Eᵢⱼ, df = (r − 1)(c − 1) Yates (2×2) χ² = Σ (|O − E| − 0.5)² / E Cramér’s V V = √( χ² / (N × min(r − 1, c − 1)) ) Adjusted residual (O − E) / √( E (1 − rowᵢ/N)(1 − colⱼ/N) ) Fisher’s exact sum of hypergeometric probabilities ≤ P(observed table), two-sided

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.
Effect size matters. With a big sample, even a tiny association becomes “significant”. Report Cramér’s V: about 0.1 is small, 0.3 medium and 0.5 large (for df = 1).
Learn the statistics behind these numbers. Codanics has free statistics, R and Python lessons on YouTube and full courses for researchers.

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.

More free tools

See all Codanics tools →

Made by Dr. Muhammad Aammar Tufail, Codanics. Found a bug or have an idea for a new tool? Tell us on the WhatsApp channel or in the YouTube comments. Results are for learning and planning; check important analyses with a statistician or your supervisor.