🧮
✓ Editorially reviewed by Derek Giordano, Founder & Editor · BA Business Marketing

Chi-Square Calculator

Chi-square statistic, degrees of freedom and p-value from observed counts

Updated October 2026

🧮
700+ calculators, no signup required
Finance · Health · Math · Science · Business
nnng.com
χ² = Σ (observed − expected)² ÷ expected, where each expected count = row total × column total ÷ grand total. For the 2×2 table 10, 20 / 30, 40, the expected counts are 12, 18, 28 and 42, giving χ² = 0.79365, p = 0.3730 with 1 degree of freedom. That is below the 3.8415 critical value at α = 0.05, so there is no evidence the two variables are related.

Entering Your Table

Type raw counts, one row per line or separated by semicolons, with values in a row separated by commas: “10, 20; 30, 40” is a 2×2 table. For a test of independence, rows are the categories of one variable (say, treatment and control) and columns the categories of the other (improved, not improved). For goodness of fit, enter one list of counts and, optionally, the expected proportions in the same order (“1, 1, 2” means 25%, 25%, 50%); blank means equal. The results give χ², degrees of freedom, the p-value, the critical value, the smallest expected count (flagged below 5) and, for tables, Cramér’s V as a measure of strength from 0 to 1.

How Chi-Square Is Calculated: the 2×2 Example

Row totals are 30 and 70, column totals 40 and 60, grand total 100. Expected counts: 30 × 40 ÷ 100 = 12, 30 × 60 ÷ 100 = 18, 70 × 40 ÷ 100 = 28 and 70 × 60 ÷ 100 = 42. Each cell contributes (O − E)² ÷ E: 4/12 + 4/18 + 4/28 + 4/42 = 0.33333 + 0.22222 + 0.14286 + 0.09524 = 0.79365. With (2 − 1) × (2 − 1) = 1 degree of freedom the p-value is 0.3730, and Cramér’s V is √(0.79365 ÷ 100) = 0.0891, a weak association.

Independence or Goodness of Fit

A test of independence asks whether two categorical variables are related; degrees of freedom are (rows − 1) × (columns − 1). A goodness-of-fit test asks whether one variable’s counts match expected proportions, such as a fair die; degrees of freedom are categories − 1 (fewer if you estimated parameters from the same data, as NIST’s handbook notes). Both compare observed counts with the counts expected if the null hypothesis were true.

Same Proportions, Different Conclusions

Tableχ²dfpSignificant at 0.05?
10, 20 / 30, 40 (default)0.793710.3730No
Same proportions, ten times the counts: 100, 200 / 300, 4007.936510.0048Yes
Default table with Yates correction (not applied by this calculator)0.446410.5040No
2×3 table: 20, 30, 50 / 30, 30, 403.111120.2111No
Goodness of fit, 60 die rolls: 8, 12, 9, 11, 14, 64.200050.5210No

Multiplying every count by ten multiplies χ² by ten, turning p = 0.373 into p = 0.0048 although the proportions are identical. Significance depends on sample size as much as on the pattern, which is why Cramér’s V (0.0891 in both tables) is worth reporting alongside p.

Critical Values at α = 0.05

Degrees of freedom1234510
Critical χ²3.8415.9917.8159.48811.07018.307

Pitfalls: Small Counts, Percentages and Yates

Entering percentages or means. The test needs raw counts. Percentages hide the sample size, which, as the table above shows, changes the answer.

Small expected counts. Penn State’s STAT 500 asks for every expected cell in a 2×2 table to be at least 5, and notes that many statisticians are wary when more than 20% of cells in a larger table fall below 5. Combine sparse categories, or use Fisher’s exact test for small 2×2 tables.

Comparing with software that applies Yates. Some programs apply a continuity correction to 2×2 tables by default. This calculator reports the uncorrected Pearson statistic; the corrected value for the default table is 0.4464 (p = 0.5040).

Counting one person twice. Each observation must fall in exactly one cell, and observations must be independent; repeated answers from the same people need a different test (McNemar’s for paired yes/no data).

Frequently Asked Questions

How do you calculate chi-square?
For each cell, compute (observed − expected)² ÷ expected and add them up; expected = row total × column total ÷ grand total.
How many degrees of freedom does a chi-square test have?
(rows − 1) × (columns − 1) for independence; categories − 1 for goodness of fit.
What is the critical chi-square value for 1 degree of freedom?
3.841 at α = 0.05; 6.635 at α = 0.01.
What if expected counts are below 5?
The p-value can be unreliable; combine categories or use Fisher’s exact test for 2×2 tables.
What does a chi-square p-value tell you?
How likely a χ² at least this large would be if the variables were unrelated (or the counts matched the expected proportions). Below α, you reject that null hypothesis.
How do I do a chi-square test in Excel?
CHISQ.TEST(actual_range, expected_range) returns the p-value, but you must build the expected-count table yourself first; it does not give χ² directly.
Does this apply the Yates correction?
No. It reports the uncorrected Pearson chi-square.

How to Use This Calculator

  1. Choose the test — independence or goodness of fit.
  2. Enter observed counts — rows separated by semicolons, values by commas.
  3. Add expected proportions (goodness of fit) — or leave blank for equal.
  4. Read the result — chi-square, degrees of freedom, p-value, expected-count check and Cramér’s V.
📚 Sources & References
  1. [1] NIST/SEMATECH e-Handbook of Statistical Methods. 1.3.5.15 Chi-square goodness-of-fit test. Accessed Oct 2026. itl.nist.gov
  2. [2] Penn State Eberly College of Science. STAT 500 Applied Statistics, Lesson 8: Chi-square test for independence. Accessed Oct 2026. online.stat.psu.edu
  3. [3] NIST Dataplot. Chi-square goodness-of-fit test reference (statistic, degrees of freedom, critical value). Accessed Oct 2026. itl.nist.gov
  4. [4] Microsoft Support. CHISQ.TEST function. Accessed Oct 2026. support.microsoft.com
✅ Editorial Standards — Every calculator is built from peer-reviewed formulas and official data sources, editorially reviewed for accuracy, and updated regularly. Read our full methodology · About the author