Chi-Square Calculator
Type or paste your counts. The chi-square test result, the exact p-value, the expected counts and an effect size update as you type, with the R and Python code that gives the same answer.
- Exact p-values, never shown as 0.000
- Expected counts checked against both common rules
- 2x2 tables show Pearson, Yates and Fisher side by side
Checked on November 21, 2026. Results computed by our statistics engine, version 1.0.0.
What the chi-square test does
A chi-square test compares the counts you observed with the counts you would expect if nothing interesting were going on. If the gap is bigger than chance usually produces, the test statistic χ² is large and the p-value is small.
There are two everyday versions. The test of independence takes a table that cross-classifies one group of people or things by two variables, such as gender and party, and asks whether the two are related. The goodness-of-fit test takes one row of counts and asks whether they match a distribution you name in advance, such as equal shares or Mendel's 9:3:3:1. The calculator above does both: use the tabs at the top to switch.
Both versions use the same statistic, χ² = Σ (O − E)² / E, the sum over every cell of the squared gap between the observed count O and the expected count E, divided by E. What changes is how E is found and how many degrees of freedom the test has. The step-by-step guide works through the arithmetic by hand.
Worked example: party identification by gender
The table pre-filled above is the example R uses in the help page for chisq.test: 2,757 people in a survey reported in Agresti's Introduction to Categorical Data Analysis, cross-classified by gender and party identification (R reference output).
| Democrat | Independent | Republican | |
|---|---|---|---|
| Female | 762 | 327 | 468 |
| Male | 484 | 239 | 477 |
If gender and party were unrelated, each row would split across the parties in the same proportions as the whole sample. The expected count for women who identify as Democrats is the row total times the column total divided by N, which comes to 703.67; 762 were observed. For women identifying as Republicans the expected count is 533.68 against 468 observed.
Adding (O − E)² / E over all six cells gives χ² = 30.0701 with (2 − 1)(3 − 1) = 2 degrees of freedom. The chance of a value at least that large when gender and party are unrelated is p = 2.954 × 10−7, far below 0.05, so there is evidence of an association. R prints exactly this: X-squared = 30.07, df = 2, p-value = 2.954e-07.
Cramér's V is 0.104, a weak association by the usual rough conventions. A survey this large can detect a small difference, which is why the effect size matters as much as the p-value. The adjusted residuals show where the difference sits: the largest in size is −5.32, in the cell for female respondents identifying as Republicans: fewer of them than independence would predict.
Reading your result
- χ² and df. The statistic grows with the size of the gaps and with the number of cells. The degrees of freedom are (rows − 1)(columns − 1) for a table and (categories − 1) for goodness of fit.
- p-value. The probability of a χ² at least this large if there were truly no association (or the counts truly followed your expected distribution). Below your significance level, usually 0.05, the result is called statistically significant.
- Expected counts. The approximation behind the p-value needs expected counts that are not too small. The calculator checks both the strict textbook rule and Cochran's more lenient rule, and says which one your table passes. See expected counts and small samples.
- Effect size. Cramér's V (or Cohen's w for goodness of fit) tells you how strong the association is, on a scale from 0 to 1. See the Cramér's V calculator.
- APA sentence. A ready-made line such as χ²(2, N = 2,757) = 30.07, p < .001, formatted as the APA reporting guide explains.
Which chi-square test to use
Use the test of independence when one sample is cross-classified by two variables, and the same arithmetic as a test of homogeneity when you sampled separate groups and recorded one variable. Use goodness of fit when you have one variable and a target distribution. For a 2x2 table, the 2x2 calculator shows the Yates-corrected and N−1 versions with Fisher's exact test, and for the same people measured twice use the McNemar test instead. The decision guide has three short examples.
Common mistakes
- Entering percentages or averages instead of counts. Chi-square needs the number of people or things in each cell.
- Counting the same person in more than one cell. Each observation must fall in exactly one cell.
- Applying the "at least 5" rule to observed counts. The rule is about expected counts.
- Reading a large p-value as proof that the variables are unrelated. It only means the data give no evidence of a relationship.
- Comparing your answer with R or SciPy on a 2x2 table without noticing that both apply the Yates correction by default. The Yates guide shows the same table both ways.
Every chi-square tool
Guides
Common questions
Is this the same as a chi-squared test?
Yes. Chi-square, chi-squared and χ² test all name the same Pearson test; spellings vary between textbooks.
Can I use percentages?
No. Convert percentages back to counts first. A chi-square test on percentages gives a wrong answer because it ignores the sample size.
Why does my p-value show as a power of ten?
Very small p-values are shown in scientific notation, so 2.954 × 10−7 means about 3 in 10 million. In APA style write p < .001.
Does my data leave my device?
No. Every result is computed in your browser.
Tested against R and SciPy
Every result on this site comes from one statistics engine that must reproduce 25 published results from R, NIST and textbooks before a page is built. See every test case, who runs this site or report a correction.
Sources
- R reference example output, stats-Ex.Rout.save checked November 21, 2026