Chi-square test calculator
Paste a crosstab of counts from 2×2 up to 5×5. You get χ², the p-value and Cramér's V, and see whether the two categorical variables are associated.
- Checked against reference values
- Free, no sign-up
- Nothing leaves your browser
Enter the contingency table
For a 2×2 table type "50 30" on the first line and "20 40" on the second, or paste the cells from Excel.
Assumptions and limitations
- Each respondent is counted in exactly one cell, and respondents are independent of each other.
- Enter counts (whole numbers of respondents), not percentages. Rows and columns from 2 to 5.
- Expected counts should be large enough: by Cochran's rule, none below 1 and no more than 20% below 5. The calculator warns you when a cell falls below 5.
- The statistic is Pearson's χ² without the Yates continuity correction.
Collect real answers in a SurveyNinja survey and see them in charts in the report.
Use this template See the questions firstData is not stored — calculation runs in your browser.
Ready-made template
Do it with your own respondents
The “Likert scale survey” template already has the questions. Put in your company name, share the link and watch the answers come in.
- Copy the template: the questions are written
- Share it by link, QR code or a widget on your site
- Read the results in the report with charts
New accounts get 14 days of Premium features, no credit card.
What is the chi-square test of independence?
The chi-square (χ²) test of independence checks whether two categorical variables are related, such as age group and a yes/no answer. It compares the observed count in each cell of a crosstab with the count expected if the variables were independent: χ² = Σ (O − E)² / E. A p-value below 0.05 means the association is statistically significant; Cramér's V shows how strong it is.
How the chi-square test works
-
What is tested
The null hypothesis says the two variables are independent. A small p-value (usually below 0.05) means counts this far from independence would be unlikely by chance, so you reject the null hypothesis and call the association statistically significant.
-
Formula
χ² = Σ (O − E)² / E, where O is the observed count in a cell and E the expected count under independence: E = row total × column total / N. The p-value is the upper tail of the chi-square distribution with df degrees of freedom.
-
Degrees of freedom
df = (rows − 1) × (columns − 1). A 2×2 table has df = 1, a 3×2 table has df = 2.
-
Strength: Cramér's V
χ² grows with sample size, so it does not show how strong the association is. Cramér's V = √(χ² / (N × (min(rows, columns) − 1))) runs from 0 (no association) to 1 (perfect association) and can be compared across tables.
Chi-square calculation examples
-
Association present (gender × purchase)
- 2×2 table. Men: 50 bought, 30 did not. Women: 20 bought, 40 did not. Enter two lines: 50 30 and 20 40.
χ² = 11.667, df = 1, p < 0.001, Cramér's V = 0.289. Purchase and gender are associated: reject independence.
-
No association
- 2×2 table with identical rows: 25 25 and 25 25. Observed counts equal the expected ones.
χ² = 0, p = 1. Nothing suggests an association.
-
3×2 table (age × yes/no)
- 18–30: 40 yes, 60 no. 31–45: 50 yes, 50 no. 46+: 30 yes, 70 no. Enter three lines of two numbers.
χ² = 8.333, df = 2, p = 0.016, Cramér's V = 0.167. The answer depends on age at the 5% level, but the association is weak.
-
Weak signal
- 2×2 table: 45 55 and 48 52. The two distributions are almost the same.
χ² = 0.181, df = 1, p = 0.671. No significant association. Finding a difference this small would need a much larger sample.
-
Strong association (region × brand)
- Region A: 80 chose brand 1, 20 brand 2. Region B: 25 and 75. Opposite preferences.
χ² = 60.652, df = 1, p < 0.001, Cramér's V = 0.551. Brand choice clearly depends on region, so segmenting by region makes sense.
-
3×2 table (channel × outcome)
- Three channels, two outcomes. Channel 1: 30 20. Channel 2: 25 35. Channel 3: 15 25.
χ² = 5.525, df = 2, p = 0.063. Not significant at the 5% level: the data do not show that the outcome depends on the channel.
Interpreting the p-value
Not significant does not prove independence: a small sample can miss a real association. If an expected count in a 2×2 table is below 5, use Fisher's exact test.
| p-value | Conclusion |
|---|---|
| p < 0.05 | Association significant: reject independence |
| p ≥ 0.05 | Association not significant: no reason to reject independence |
Next step
Collect the data for this analysis
Build the survey in SurveyNinja, share the link in your email or chat, or as a QR code, and export the answers to Excel, CSV or SPSS on every plan.
- Ready questions or AI from a description
- A link for your email or chat, a QR code or a widget on your site
- Charts in the report, export to Excel, CSV and SPSS
Frequently asked questions about chi-square
What does chi-square show?
How far the observed counts are from the counts expected if the two variables were independent. A large χ² with a small p-value points to an association; Cramér's V shows how strong it is.
How do I enter the table?
One line per category of the first variable, with the counts for each category of the second variable separated by spaces or commas. All lines need the same number of values. You can paste a block of cells straight from Excel or Google Sheets.
Why should expected counts be at least 5?
The p-value comes from the chi-square distribution, which approximates the exact distribution of χ² only when expected counts are not too small. Cochran's rule: no expected count below 1 and no more than 20% of cells below 5. For a 2×2 table with small counts, use Fisher's exact test; for bigger tables, merge sparse categories.
How is chi-square related to an A/B test?
For a 2×2 table (variant × converted or not) Pearson's χ² equals the square of the z of the pooled two-proportion test, so both give the same p-value. Chi-square also works for tables with more rows and columns.
What is the p-value here?
The probability of getting a χ² this large or larger if the variables were really independent. It is not the probability that the variables are independent. p < 0.05 is the usual threshold for calling an association significant.
Does the calculator apply the Yates correction?
No. It reports Pearson's χ² without continuity correction, the value statistics packages show as "Pearson chi-square". The Yates correction gives a smaller χ² and a larger p-value for 2×2 tables.
Sources
- Cochran, W. G. (1954). Some methods for strengthening the common χ² tests. Biometrics, 10(4), 417–451
- Agresti, A. (2007). An Introduction to Categorical Data Analysis, 2nd ed. Wiley
Learn the method
Read how the method works and where its numbers come from.
Turn the numbers into a survey
Start from the “Likert scale survey” template: the questions are ready.
Cross-Sectional Study vs Longitudinal Study: Differences, Types and Survey Examples