Chi-Square Calculator

Run a chi-square test of independence or goodness of fit on a table up to 5x5, see expected counts, residuals, Cramer's V and p-value. Free.

Examples:
Observed counts. Edit the labels and the counts.
Observed countsTotal
50
50
Total4555100

Yates continuity correction (2 × 2 only)

Up to 5 × 5. Enter counts, not percentages.

χ² statistic

9.091

Degrees of freedom

1

p-value

0.0026

Cramér's V

0.302

medium effect

φ (phi)

0.302

sign follows row and column order

Fisher exact p

0.0046

two-sided, 2 × 2

p is below 0.05. The counts differ from what independence predicts by more than chance alone would usually produce, so the rows and columns look related.

APA result

χ²(1, N = 100) = 9.09, p = .003, φ = .30

Expected counts

Expected counts under independence
ImprovedNot improved
Treatment22.527.5
Control22.527.5

Expected = row total × column total ÷ N. Cells under 5 are highlighted.

Standardized residuals

Adjusted standardized residuals
ImprovedNot improved
Treatment+3.02-3.02
Control-3.02+3.02

(O − E) ÷ √(E × (1 − row share) × (1 − column share)). Blue means more than expected, orange fewer; bold is beyond ±1.96.

Residual heatmap

Chi-square test of independenceχ²(1, N = 100) = 9.09, p = .003, φ = .30Smallest expected count 22.5.ImprovedNot improvedTotalTreatment30E 22.5z +3.0220E 27.5z -3.0250Control15E 22.5z -3.0235E 27.5z +3.0250Total4555100-3-2-10+1+2+3Adjusted residual zfewer than expectedmore than expectedExpected = row total × column total ÷ N. Adjusted residual = (O − E) ÷ √(E × (1 − row share) × (1 − column share)); beyond±1.96 is a cell that departs from independence at about the 5% level.Cramér's V and φ use the uncorrected χ². Checked against SciPy 1.18.1 on random inputs: chi2_contingency (154 tables, 2×2 to5×5), chisquare (81 cases) and fisher_exact (153 tables).conceptviz.app/tools/chi-square-calculator

Want the critical value instead of the p-value? Look up df = 1 in the chi-square table.

Free Chi-Square Calculator Charts

Every chart below is drawn from the same code as the calculator above. View and download them free, no sign-up.

Independence

Chi-Square Residual Heatmap (2 × 3)

Observed count, expected count and adjusted residual in every cell: χ² = 11.111, df 2, p = 0.0039.

1 / 5

Worked examples

How to calculate

How to choose

To compare your statistic with a cut-off instead of a p-value, use the chi-square table. To compute d, g or eta squared for numeric data, try the effect size calculator, and to turn a grid of values into a color-coded chart, use the heatmap generator. To lay out your counts as a labeled table first, use the two-way table generator.

What a chi-square test tells you

  • A chi-square (χ²) test compares counts you observed with the counts you would expect if a simple hypothesis were true. The statistic is the sum of (observed − expected)² ÷ expected over every cell or category. The more the data depart from the hypothesis, the larger χ² gets, and the p-value is the chance of a statistic at least that large when the hypothesis holds. The test works on counts of people, events or items, never on percentages or means.
  • This calculator runs both common versions. Use the test of independence when each observation falls into one row and one column of a table, for example treatment group by outcome. Use goodness of fit when one categorical variable has a hypothesis for the share of each category, such as an even split or a 9:3:3:1 ratio.

Independence or goodness of fit?

The test of independence asks whether two categorical variables are related. Expected counts come from the margins: row total × column total ÷ N, and the degrees of freedom are (rows − 1) × (columns − 1). Goodness of fit asks whether one variable follows a stated distribution. Expected counts are the hypothesised share × N, and the degrees of freedom are categories − 1, minus one more for each parameter estimated from the data. Both use the same right-tail p-value; only the way the expected counts and degrees of freedom are found differs.

Assumptions to check first

Each observation must be counted once and be independent of the others, so repeated measures on the same person need a different test. The categories must not overlap. The usual rule of thumb is that expected counts should be about 5 or more, and the calculator warns you when more than 20% of the cells fall below 5. For a 2 × 2 table it then shows Fisher’s exact test, which does not rely on the χ² approximation. A larger table with sparse cells can often be fixed by combining categories that make sense together.

How to read expected counts and residuals

  • The χ² statistic only says that something differs. The residuals say where. The standardized residual here is the adjusted one, (O − E) ÷ √(E × (1 − row share) × (1 − column share)), which behaves roughly like a z-score. A value beyond ±1.96 marks a cell that departs from independence at about the 5% level; positive means more observations than expected, negative fewer. In the 2 × 3 example above, the Group A / Low cell has an adjusted residual of 3.33, the largest single share of the χ² of 11.111. For goodness of fit the table shows the simpler Pearson residual (O − E) ÷ √E, where about ±2 is large.
  • With many cells, expect an occasional large residual by chance alone, so read the pattern rather than a single cell.

Yates correction, Fisher and effect size

  • A significant p-value does not say how strong the link is, so the calculator also reports Cramér's V, which runs from 0 to 1 (φ for a 2 × 2 table), and Cohen's w for goodness of fit. For a 2 × 2 table, Yates' continuity correction subtracts 0.5 from each |O − E| before squaring. It is off by default and available only for 2 × 2 tables. On the table [[10, 20], [30, 40]] it changes χ² from 0.794 to 0.446 and p from 0.3730 to 0.5040; Fisher's exact test gives p = 0.5045. Cramér's V and φ are always computed from the uncorrected χ².

Frequently Asked Questions