Chi-Square Calculator

Goodness-of-fit and independence tests with p-value and Cramér's V.

About this tool

For goodness of fit, enter the observed counts and, optionally, the expected counts or proportions; leave expected blank to test against equal frequencies. For independence, paste a table of observed counts, one row per line. Choose a significance level. The calculator shows χ², degrees of freedom, the p-value, whether the result is significant, Cramér's V for tables and the expected counts, with a warning when any are too small.

How the chi-square test works

The chi-square test compares observed counts with the counts you would expect if the null hypothesis were true. For each cell it calculates (observed − expected)² ÷ expected and adds them up. The bigger χ² is, the further the data are from the expectation. The p-value comes from the chi-square distribution with the right degrees of freedom: categories − 1 for goodness of fit, and (rows − 1) × (columns − 1) for a table. A goodness-of-fit example: 60 rolls of a die produce 8, 9, 12, 11, 6 and 14 of each face against an expected 10 each. χ² = 4.2 with 5 degrees of freedom gives p ≈ 0.52, so there's no evidence the die is unfair. A test of independence asks whether two categorical variables are related. In the table 20 30 / 30 20, expected counts are 25 in every cell, χ² = 4.0 with 1 degree of freedom and p ≈ 0.046, significant at the 5% level. Cramér's V, here 0.2, measures the strength of the association from 0 to 1. Honest limits: use raw counts, never percentages, and each observation should fall in only one cell. The test is unreliable when expected counts are below 5; for small 2 × 2 tables, Fisher's exact test is better. This calculator doesn't apply Yates' continuity correction. The t-test calculator compares means, the z-score calculator handles normal probabilities and the sample size calculator plans surveys. How A/B testing works — and the three ways it lies puts significance testing in context.

Frequently asked questions

What does the chi-square p-value mean?

The probability of seeing a χ² this large or larger if the null hypothesis were true. Below 0.05 is commonly called significant.

How do I calculate degrees of freedom for chi-square?

Categories − 1 for goodness of fit; (rows − 1) × (columns − 1) for a contingency table.

When should I not use a chi-square test?

When expected counts are below 5 in many cells, or when the data are percentages or measurements rather than counts.

Is my data saved?

No. The calculation runs in your browser and nothing is stored or sent.