Chi-square test calculator (test of independence, p-value)
Run a chi-square test of independence on a contingency table and get the p-value.
The chi-square calculator runs a test of independence on an observed contingency table (2×2 up to 6×6). It computes the expected frequency for each cell, the chi-square statistic, the degrees of freedom and the p-value, so you can judge whether two categorical variables are associated. It does not apply a continuity correction, and it is not a goodness-of-fit test.
Observed frequencies
How to use
- Set the number of rows and columns to match your contingency table, then fill in the observed frequency in each cell.
- Click "Calculate" to get the chi-square statistic, degrees of freedom, p-value, and the expected frequencies under independence.
Common use scenarios
- Testing whether two categorical variables (e.g. group and outcome) are related.
- Checking survey response data for association between two categorical questions.
- Verifying a chi-square result reported in a paper or spreadsheet.
- Comparing observed counts against what independence would predict.
✓Content & verification reviewed: 2026-10-03
How we verify Chi-square test calculator (test of independence, p-value)
How to confirm the chi-square result matches what you'd expect.
Expected frequencies come from row and column totals under independence
Each cell's expected frequency is (row total × column total) ÷ grand total — this is what you'd expect to see in that cell if the two variables had no relationship at all.
A larger chi-square statistic means observed and expected differ more
The statistic sums, across every cell, the squared difference between observed and expected divided by expected — so large discrepancies in any cell (especially ones with small expected counts) can drive the statistic up substantially.
Degrees of freedom is (rows - 1) × (columns - 1)
This determines which reference chi-square distribution the p-value is computed from — a 2×2 table has 1 degree of freedom, a 3×3 table has 4, and so on.
Before you rely on the result
- Your rows and columns represent categories, not numeric measurements to correlate.
- You've checked that expected frequencies aren't too small — the approximation is less reliable below about 5 per cell.
- You're interpreting the p-value as evidence of association, not the strength or direction of it.
- The row/column dimensions match your actual table before reading the result.
Who this is for
- Researchers testing association between two categorical variables.
- Students verifying a chi-square result against a textbook or paper example.
- Analysts checking survey data for a relationship between two categorical questions.
- Anyone comparing observed category counts against an independence assumption.
Real-world examples
Survey cross-tabulation
A researcher builds a table of two categorical survey questions and tests whether the responses to one are related to the responses to the other.
Comparing groups on a categorical outcome
An analyst compares counts of a categorical outcome (e.g. pass/fail) across several groups to see if the outcome depends on group membership.
Verifying a published result
A student re-enters an observed table from a paper or textbook to confirm the reported chi-square statistic and p-value.
Limitations
- This tests independence between two categorical variables, not correlation between numeric ones — and the chi-square approximation is less reliable when expected frequencies in any cell are below about 5.
Frequently asked questions
How do I calculate a chi-square test of independence?
Set the number of rows and columns to match your table, type the observed count in each cell, and click Calculate. You get the chi-square statistic, degrees of freedom, p-value and the expected frequencies.
How do I calculate expected frequencies for a chi-square test?
Each expected value is (row total × column total) ÷ grand total. The calculator shows the full table of expected frequencies under the independence assumption.
Does this do a chi-square goodness-of-fit test?
No — it tests independence in a table with at least two rows and two columns. A goodness-of-fit test compares one row of counts to expected proportions, which this tool doesn't do.
Does the 2×2 result use Yates' continuity correction?
No. The result is the standard Pearson chi-square statistic with no correction, so a 2×2 table may differ slightly from software that applies Yates' correction by default.
What's the difference between this and a correlation calculator?
Correlation measures a linear relationship between two numeric variables. This chi-square test measures whether two categorical variables are independent of each other — it doesn't apply to continuous numeric data directly.
What does a very small p-value mean here?
It means the observed table would be unlikely if the two categorical variables were truly independent — evidence of some association, though the test doesn't say how strong or in what direction.
Why do small expected frequencies matter?
The chi-square approximation becomes less accurate when many cells have expected counts below about 5, which can make the p-value unreliable. The tool doesn't warn you, so check the expected-frequency table it shows.
How large can my table be?
Any size with at least 2 rows and 2 columns — the calculator supports contingency tables up to 6×6.
🔒 Runs in your browser — nothing is uploaded. Results are for reference only; see the disclaimer. Last updated: 2026-10-03
Subscribe for updates
New tools and tips, straight to your inbox. No spam, unsubscribe anytime.