CALCULATOR · REPORTING
Chi-Square and Fisher's Exact Calculator for Contingency Tables
Enter the counts of a table from 2 × 2 up to 5 × 5 in this chi-square calculator. The test with its expected counts, Fisher's exact test for a 2 × 2 table and Cramér's V update as you type. Nothing you enter leaves your browser.
Runs in your browser. No data is sent or stored.
Method reviewed by an in-house statistician · Last checked November 2026
In Short
A chi-square calculator tests whether two categorical variables are associated by comparing the observed counts in a table with the counts expected if they were independent. This one accepts tables from 2 × 2 to 5 × 5, shows every expected count and flags any below 5, and reports Cramér’s V as a measure of the strength of the association. For a 2 × 2 table it also computes Fisher’s exact test, which is recommended when any expected count is below 5. A chi-square p-value tests association; the size of the association is carried by V or, for a 2 × 2 table, by a ratio of risks or odds.
How It Is Calculated
The Pearson chi-square statistic compares each observed count (O) with its expected count (E) under independence (Agresti, 2013):
r = number of rows · c = number of columns · N = total count · p from the χ² distribution with df degrees of freedom.
For a 2 × 2 table, an optional Yates continuity correction is available. It is off by default:
Fisher’s exact test for a 2 × 2 table gives a two-sided p-value as the sum of the probabilities of all tables with the same margins whose probability is no larger than that of the observed table, the convention of R’s fisher.test. Cramér’s V scales the statistic to the table:
For a 2 × 2 table, V equals the absolute value of the phi coefficient.
The page flags any expected count below 5. For a 2 × 2 table it then recommends Fisher’s exact test. For a larger table it warns that the chi-square approximation may be unreliable and that an exact or Monte Carlo test in statistical software is advisable. It does not substitute any other result. The N − 1 chi-square (Campbell, 2007) is a further option that is not implemented.
Assumptions and When Not to Use It
- Independent observations. Each participant is counted once, in one cell. Matched pairs and repeated measurements on the same people need a different test; see Which Statistical Test Should I Use? A Research Decision Guide.
- Counts, not percentages. Enter whole numbers of participants. Rows and columns cannot be empty, and the total must be at least 1.
- Expected counts large enough. The approximation is the concern when an expected count is below 5. For a 2 × 2 table, see Fisher’s Exact Test. For a larger table with expected counts below 5, use an exact or Monte Carlo test in statistical software.
- An association, not an effect size. The p-value does not say how strong the association is. For a 2 × 2 table, report the Odds Ratio Calculator or the Relative Risk Calculator result with its interval.
- One test, chosen in advance. Picking between the chi-square and Fisher’s test after seeing which p-value is smaller is a choice made after the result. State the rule before the analysis.
- Valid tables. Counts must be non-negative integers, from 2 × 2 up to 5 × 5.
Worked Example (Hypothetical Values)
A study cross-tabulates a binary outcome against two exposure groups of 20 participants each: 12 and 8 in the first row, 4 and 16 in the second.
| Input or result | Value |
|---|---|
| Table, row 1 | 12, 8 |
| Table, row 2 | 4, 16 |
| Chi-square (df = 1) | 6.6667 |
| p-value, two-sided, beside the statistic | 0.0098 |
| Cramér’s V | 0.4082 |
| Smallest expected count | 8.0 |
| Fisher’s exact test, p-value | 0.0225 |
| With Yates correction: chi-square, p-value | 5.1042, 0.0239 |
Every expected count is at least 5, so the chi-square approximation is not in question, and Fisher’s exact test and the Yates correction give larger p-values, 0.0225 and 0.0239, that are also below 0.05. Press “Load the worked example” under the calculator and these values fill the fields. HYPOTHETICAL VALUES.
What the Result Still Needs
- 1
A table that matches the design. Each participant appears once, and the table is not a before-and-after comparison on the same people.
- 2
Expected counts inspected. The smallest expected count is reported, and any value below 5 is handled with an exact test, not by trusting the approximation.
- 3
A strength measure beside the p-value. Cramér’s V for a larger table, or a risk ratio or odds ratio with its confidence interval for a 2 × 2 table.
- 4
The test named in the report. Pearson chi-square, with or without continuity correction, or Fisher’s exact test, as chosen before the analysis.
- 5
Counts shown with the result. The table of observed counts accompanies the statistic, so a reader can see where the association comes from.
A statistician checks the table against your design, chooses between the chi-square and an exact test, adds the effect measure and writes the results sentence for your manuscript.
Quantitative Data AnalysisIndependent Statistical Review confirms an analysis prepared by you, a colleague or an AI tool before it goes to a committee or a journal.
Independent Statistical ReviewFrequently Asked Questions
When should I use Fisher's exact test instead of the chi-square test?
Fisher’s exact test is recommended for a 2 × 2 table when any expected count is below 5. The calculator computes it for every 2 × 2 table, so you can compare. Choose the rule before you look at the p-values.
What if my table is larger than 2 × 2 and an expected count is below 5?
The page warns that the chi-square approximation may be unreliable and does not substitute any other result. An exact or Monte Carlo test in statistical software is advisable. Combining categories after seeing the data is a decision to report, not a quiet fix.
Should I turn on the Yates correction?
It is optional and off by default. In the worked example it moves the chi-square from 6.6667 to 5.1042 and the p-value from 0.0098 to 0.0239. Report whether you used it, and decide before the analysis.
What does Cramér's V tell me that the p-value does not?
It scales the chi-square statistic by the sample size and the table dimension, so it describes how strong the association is, whatever the p-value. For a 2 × 2 table, it equals the absolute value of phi. Report V with the p-value, not instead of it.
Can I enter percentages or matched data?
No. The calculator needs whole-number counts from independent observations. Percentages hide the sample size, and matched pairs call for a test that respects the pairing. Enter the counts from the original table.
References
- Agresti, A. (2013). Categorical data analysis (3rd ed.). Wiley.
- Campbell, I. (2007). Chi-squared and Fisher-Irwin tests of two-by-two tables with small sample recommendations. Statistics in Medicine, 26(19), 3661-3675. https://doi.org/10.1002/sim.2832
Method reviewed by an in-house statistician · Last checked November 2026 · Test cases and boundary cases verified before release
Found an error or have a suggestion? Write to info@onlinespss.com with the calculator name and the inputs you used. Every report is checked by a statistician.
Have a Statistician Check Your Contingency Table Analysis
Share the study aim, the variables and the table of counts. A statistically trained Research Coordinator reviews the request, and the scope and one fixed project fee are confirmed before work begins.
No Commitment Required
Strictly Confidential
Fixed Project Fee
In-House PhD-Level Statisticians
Same-Day Response