Chi-Square Test Calculator
Run a chi-square goodness-of-fit test or a test of independence on a contingency table. Get the statistic, degrees of freedom, exact p-value and Cramér's V.
Decision
Reject the null hypothesis (p ≤ α = 0.05)
Cramér's V = √(χ² / (N · min(r−1, c−1)))
Observed, expected and contribution to χ²
| Cell | Observed | Expected | O − E | (O−E)²/E |
|---|---|---|---|---|
| Row 1, Col 1 | 20 | 25 | -5 | 1 |
| Row 1, Col 2 | 30 | 25 | 5 | 1 |
| Row 2, Col 1 | 30 | 25 | 5 | 1 |
| Row 2, Col 2 | 20 | 25 | -5 | 1 |
E = row total × column total ÷ grand total, df = (rows − 1)(columns − 1). p comes from the regularized incomplete gamma function.
What is the Chi-Square Test Calculator?
The ByteTools Chi-Square Test Calculator handles both chi-square tests taught in a statistics course.
- Goodness-of-fit and independence tests in one page
- Accepts expected counts or proportions, or assumes equal proportions
- Full per-cell table of observed, expected, O − E and (O−E)²/E
- Cramér's V and Cohen's w effect sizes
- Automatic warning when an expected cell is below 5
- Runs entirely in your browser — no data leaves the page
How to use the Chi-Square Test Calculator
- 1
Choose goodness of fit or a test of independence.
- 2
For goodness of fit, paste the observed counts and optionally the expected counts or proportions.
- 3
For independence, paste the contingency table with one row per line and columns separated by spaces, commas or tabs.
- 4
Pick your significance level alpha.
- 5
Read the chi-square value, df, p-value, effect size and the per-cell contribution table, then click Copy results.
About the Chi-Square Test Calculator
The ByteTools Chi-Square Test Calculator handles both chi-square tests taught in a statistics course. Goodness of fit compares one row of observed counts against expected counts or equal proportions. The test of independence takes an r × c contingency table and asks whether the two categorical variables are related.
Along with the chi-square statistic, degrees of freedom and an exact p-value, the tool prints the full cell-by-cell working: the expected count, the raw difference and each cell's contribution to the total. It also reports an effect size — Cramér's V for independence, Cohen's w for goodness of fit — and warns you when any expected cell falls below 5, which is the point where the chi-square approximation stops being trustworthy.
Every calculation runs client-side in your browser using a hand-written regularized incomplete gamma function, which is why the p-value matches statistical software instead of a rounded printed table. Your counts are never uploaded, logged or stored anywhere, so the tool stays private, responds instantly and remains available when you are offline.
Frequently asked questions
What is the difference between a chi-square goodness-of-fit test and a test of independence?
Goodness of fit compares one categorical variable against a set of expected proportions, such as testing whether a die is fair. A test of independence uses a two-way table and asks whether two categorical variables are associated, such as whether treatment group is related to outcome.
How do you calculate the expected counts in a contingency table?
Each expected count is the row total multiplied by the column total, divided by the grand total. That is the count you would see if the two variables were completely independent, which is exactly the null hypothesis the test is checking.
What happens if an expected count is less than 5?
The chi-square statistic only approximately follows a chi-square distribution, and that approximation degrades when expected counts get small. The usual guidance is that no expected cell should be under 5. This tool flags it and you can respond by merging categories or switching to Fisher's exact test.
What does Cramér's V tell me that the p-value does not?
The p-value tells you whether an association is detectable, which depends heavily on sample size. Cramér's V measures how strong the association is on a 0 to 1 scale that does not grow with n, so a huge sample can produce a tiny p-value alongside a V of 0.05 that says the effect is negligible.
How many degrees of freedom does a chi-square test have?
For goodness of fit it is the number of categories minus 1, minus one more for every parameter you estimated from the data. For a test of independence it is (rows − 1) × (columns − 1), so a 2 × 2 table has 1 degree of freedom.
Related tools
P-Value Calculator
Turn a z, t, chi-square or F test statistic into left-tail, right-tail and two-tailed p-values, with the critical value and a reject or fail-to-reject verdict.
T-Test Calculator
Run a one-sample, paired or two-sample t-test from raw data. Get t, degrees of freedom, exact p-values, the critical value, Cohen's d and a confidence interval.
One-Way ANOVA Calculator
Build a complete one-way ANOVA table from pasted groups: sums of squares, degrees of freedom, mean squares, the F statistic, an exact p-value and eta squared.
Frequency Distribution Calculator
Group raw data into classes using Sturges' rule, the square-root rule or a width you choose, then get frequencies, cumulative columns, grouped stats and a histogram.
Probability Calculator
Work out probabilities for one or two events: complement, union, intersection, conditional probability and the chance of at least one success in n trials.