Chi-Square Test Calculator

This chi-square calculator runs a goodness-of-fit test or a chi-square test of independence on a contingency table. Enter your observed counts to get the chi-square statistic, expected counts, degrees of freedom, p-value, residuals and an effect size.

Columns separated by commas or spaces.

Checks on your data

  • Expected counts are large enough for the chi-square approximation.
  • Each observation must be counted once and fall in exactly one cell. Percentages or repeated measures on the same people break the test.

Results

Chi-square statistic χ²
9.86364
p-value
0.0072134
Decision at α = 0.05
Reject H₀
Degrees of freedom
2
Critical value (α = 0.05)
5.9915
Cramér’s V (effect size)
0.2654
Sample size N
140
Smallest expected count
15
meets the usual rule of 5
Cells with E < 5
0 %
should be under 20%
χ² distribution, df = 2: shaded = rejection region (α = 0.05)
510χ² = 9.864
Standardised residuals per cell (|value| above 2 is notable)
00.511.5R1C1: 1.85164R1C11.85R1C2: -0.735612R1C2-0.736R1C3: -1.29099R1C3-1.29R2C1: -1.60357R2C1-1.6R2C2: 0.637059R2C20.637R2C3: 1.11803R2C31.12
Expected counts (with standardised residuals in brackets)
Col 1Col 2Col 3
Row 121.43 (1.85)23.57 (-0.736)15 (-1.29)
Row 228.57 (-1.6)31.43 (0.637)20 (1.12)
Show step-by-step solution
  1. Row totals: 60, 80; column totals: 50, 55, 35; grand total 140.
  2. Expected count for each cell = (row total × column total) ÷ grand total.
  3. χ² = Σ (O − E)² ÷ E = 9.86364.
  4. Degrees of freedom = (2 − 1)(3 − 1) = 2.
  5. p-value = P(χ²(2) ≥ 9.8636) = 0.0072134; critical value = 5.9915.
  6. p < α, so we reject H₀.
TestsCounts in categories
Statisticχ² = Σ(O − E)²/E
df (independence)(rows − 1)(cols − 1)
RuleExpected counts ≥ 5

What Is Chi-Square Test?

A chi-square test compares observed counts with the counts you would expect if a hypothesis were true. A goodness-of-fit test checks one categorical variable against expected proportions; a test of independence checks whether two categorical variables in a table are associated.

The calculator shows the expected count for every cell, flags cells with an expected count below 5, and reports Cramér's V as an effect size, so you can judge how large the association is as well as whether it is statistically significant.

Below you will find the formulas, a variables table, a worked example and answers to common questions such as how to find degrees of freedom and what to do when expected counts are small.

How to Use the Chi-Square Test Calculator

  1. Choose independence (a table of counts) or goodness of fit (a single list).
  2. Enter the observed counts. For goodness of fit you may add expected proportions; leave blank for equal expectation.
  3. Select α. Read the p-value and decision.
  4. Check the standardised residuals: cells with absolute values above about 2 are the ones that differ most from expectation.

Chi-Square Test Formula

Chi-square statistic

χ2=∑(Oi−Ei)2Ei\chi^2=\sum\frac{(O_i-E_i)^2}{E_i}

Expected count in a contingency table

Eij=(row i total)(column j total)NE_{ij}=\frac{(\text{row } i \text{ total})(\text{column } j \text{ total})}{N}

Degrees of freedom

dfGOF=k−1,dfind=(r−1)(c−1)df_{GOF}=k-1,\quad df_{ind}=(r-1)(c-1)

Cramér’s V

V=χ2N (min⁡(r,c)−1)V=\sqrt{\frac{\chi^2}{N\,(\min(r,c)-1)}}

Standardised residual

zij=Oij−EijEijz_{ij}=\frac{O_{ij}-E_{ij}}{\sqrt{E_{ij}}}

Chi-Square Test Variables Explained

SymbolMeaningNotes
χ²Chi-square statisticΣ (O − E)² ÷ E
OObserved countFrom your data
EExpected countRow total × column total ÷ N
dfDegrees of freedom(rows − 1)(columns − 1), or categories − 1
VCramér's VEffect size from 0 to 1

Chi-Square Test Worked Example

Using the example values (press “Load example” above to try them):

  1. Row totals: 60, 80; column totals: 50, 55, 35; grand total 140.
  2. Expected count for each cell = (row total × column total) ÷ grand total.
  3. χ² = Σ (O − E)² ÷ E = 9.86364.
  4. Degrees of freedom = (2 − 1)(3 − 1) = 2.
  5. p-value = P(χ²(2) ≥ 9.8636) = 0.0072134; critical value = 5.9915.
  6. p < α, so we reject H₀.

Result: Chi-square statistic χ² = 9.86364; p-value = 0.0072134; Decision at α = 0.05 = Reject H₀.

Goodness of fit vs independence vs homogeneity

Independence and homogeneity use exactly the same calculation, so this tool covers both; the difference is in how the data were collected and how you word the conclusion.

The chi-square family
TestQuestionData
Goodness of fitDoes one variable match a given distribution?One list of category counts
IndependenceAre two variables associated?One sample, cross-classified in a table
HomogeneityDo several populations share the same distribution?Separate samples, same table layout

Effect size: Cramér’s V

A significant chi-square only says an association exists; with a big sample even a tiny association is significant. Cramér’s V rescales χ² to a 0–1 range so you can judge strength.

Cramér’s V guidelines (Cohen, by degrees of freedom of the smaller dimension)
min(r, c) − 1SmallMediumLarge
10.100.300.50
20.070.210.35
30.060.170.29

Assumptions and when the test is unreliable

  • Counts, not percentages or means: enter raw frequencies.
  • Independent observations: each subject appears in only one cell.
  • Expected counts of at least 5 in most cells (rule of thumb: all at least 1 and no more than 20% below 5).
  • For a 2 × 2 table with small expected counts use Fisher’s exact test; the Yates correction shown here is a more conservative alternative.
  • Categories must be mutually exclusive and cover all cases.

Finding where the difference is

A significant overall result does not say which cells are responsible. The standardised residual compares each cell’s observed count with expectation in standard-deviation-like units. Values beyond ±2 are unusual, beyond ±3 very unusual. With many cells a few will exceed 2 by chance, so adjust the threshold (for example Bonferroni) when scanning large tables.

Where Chi-Square Test Is Used

Survey cross-tabs

Checking whether answers differ between groups, such as age band and preference.

Fairness checks

Testing whether observed counts match expected proportions, such as a die or a split of categories.

Classroom problems

Working a contingency-table problem with expected counts and residuals shown.

Reporting an association

Giving the statistic, df, p-value and Cramér's V together.

Common Chi-Square Test Mistakes to Avoid

  • Never enter percentages; convert back to counts first.
  • Merge sparse categories sensibly if expected counts are too small.
  • Report χ², df, N, p and Cramér’s V together.
  • A non-significant result does not prove independence, especially in small samples.

Chi-Square Test Terms and Definitions

Observed count
The number of cases actually counted in a cell.
Expected count
The count predicted by the null hypothesis.
Contingency table
A cross-tabulation of two categorical variables.

Chi-Square Test FAQs

What does a chi-square test tell you?

Whether observed category counts differ from expected counts by more than chance, either against a stated distribution or for an association between two variables.

How do I calculate chi-square by hand?

For each cell subtract the expected count from the observed count, square it, divide by the expected count and add the results.

What are the degrees of freedom?

For goodness of fit, categories minus 1. For a contingency table, (rows − 1) × (columns − 1).

What is a good p-value for chi-square?

A p-value below your α (commonly 0.05) indicates a statistically significant difference or association. The p-value does not tell you the strength of the association; use Cramér’s V.

Can I use percentages?

No. The test needs raw counts because the sample size determines the evidence. Convert percentages back to counts if you know the total.

What if my expected counts are below 5?

Combine categories if sensible, collect more data, or use an exact test such as Fisher’s for 2 × 2 tables.

What is the difference between chi-square and a t-test?

Chi-square analyses counts in categories; a t-test compares means of numeric data.

What should I do if expected counts are below 5?

The chi-square approximation can be unreliable when expected counts are small. Combine categories where that makes sense, collect more data, or use an exact test such as Fisher's exact test for a 2×2 table. The calculator flags cells with an expected count below 5.

How do I find the p-value or critical value for my chi-square?

The calculator reports the p-value for your table. To look up a p-value or critical value for any statistic and degrees of freedom, use the chi-square p-value calculator linked below.

Related calculators

Last updated 2026-11-09. See our disclaimer.