Chi-Square Calculator
Calculate Chi-Square (χ²) Goodness of Fit and Test of Independence instantly. View step-by-step calculations, p-values, expected frequencies, Cramér's V effect size, and export professional statistical reports — free and browser-based.
Observed vs. Expected Frequencies
| Category | Observed | Expected | |
|---|---|---|---|
Chi-Square Statistic (χ²)
5.0000
Fail to reject the null hypothesisDegrees of Freedom
2
P-value
0.0821
Significance (α)
0.05
Interpretation
With χ² = 5.0000 and 2 degrees of freedom, the p-value (0.0821) is not below α = 0.05, so there isn't enough evidence that the observed frequencies differ from the expected frequencies.
Contribution Heatmap
| Category | Observed | Expected | Contribution |
|---|---|---|---|
| Category 1 | 50 | 40 | 2.5000 |
| Category 2 | 40 | 40 | 0.0000 |
| Category 3 | 30 | 40 | 2.5000 |
Export
What Is a Chi-Square Calculator?
A chi-square calculator is a free browser-based statistical tool that performs the two most common chi-square (χ²) hypothesis tests: the Goodness of Fit test, which checks whether observed category counts match an expected distribution, and the Test of Independence, which checks whether two categorical variables in a contingency table are related.
Enter your observed frequencies — a simple category list for goodness of fit, or a full contingency table for independence — and the calculator instantly computes the chi-square statistic, degrees of freedom, p-value, effect size, and a plain-language decision, along with every intermediate step so you can verify the math yourself.
This tool is built for students, teachers, researchers, business analysts, data analysts, healthcare professionals, scientists, university professors, and statisticians. It runs entirely in your browser — no data is ever sent to a server, and results update instantly as you edit the table.
How the Chi-Square Calculator Works
For a Goodness of Fit test, you provide an observed and expected count for each category. For a Test of Independence, you provide a contingency table of observed counts, and the calculator derives expected counts from the row and column totals under the assumption that the two variables are unrelated.
Core Formulas
χ² = Σ ((Observed − Expected)² ÷ Expected)
Expected (independence) = (Row Total × Column Total) ÷ Grand Total
df = categories − 1 | df = (rows − 1) × (columns − 1)
- →Chi-Square Statistic: The sum of squared, normalized deviations between observed and expected counts — larger values indicate a bigger mismatch.
- →P-value: Computed from the chi-square distribution using the regularized incomplete gamma function — the probability of seeing a statistic this extreme if the null hypothesis were true.
- →Cramér's V: An effect size for the Test of Independence, showing how strong the association between variables is, independent of sample size.
- →Standardized Residuals: Show which specific cells in a contingency table contribute most to the chi-square statistic and in which direction.
How to Use the Chi-Square Calculator
Step-by-Step Guide
- 1Choose Your Test Type: Select Goodness of Fit to compare one set of categories against expected values, or Test of Independence to analyze a contingency table.
- 2Build Your Table: Add or remove categories (goodness of fit) or rows and columns (independence) to match your dataset, then type in your observed counts.
- 3Set Expected Values: For goodness of fit, enter your expected count per category. For independence, expected counts are calculated automatically from your table.
- 4Choose a Significance Level: Select 0.10, 0.05, or 0.01, or enter a custom alpha value.
- 5Read the Live Results: The chi-square statistic, degrees of freedom, p-value, and decision update instantly as you edit the table.
- 6Review the Heatmap and Residuals: Spot which categories or cells contribute most to the result using the color-coded contribution heatmap and, for independence tests, the standardized residuals.
- 7Export or Share: Copy the report, or download it as CSV, TXT, or JSON, and print a formatted version.
Key Features
- ✓Goodness of Fit and Test of Independence in one tool
- ✓Dynamic table builder — add or remove categories, rows, and columns
- ✓Automatic expected frequency calculation for contingency tables
- ✓Chi-square statistic, degrees of freedom, and p-value computed from the exact chi-square distribution
- ✓Cramér's V effect size for contingency tables
- ✓Color-coded contribution heatmap highlighting the biggest deviations
- ✓Standardized residuals showing direction and size of each cell's deviation
- ✓Low expected frequency warning (values under 5) per standard statistical guidance
- ✓0.10, 0.05, 0.01, or custom significance level
- ✓Random Example generator for quickly exploring the tool
- ✓Instant calculation with a 150ms debounce as you type
- ✓Export report as CSV, TXT, or JSON, plus a printable layout
- ✓Calculation history — save and review up to 20 past tests
- ✓All processing runs locally — no data leaves your browser
Real-World Use Cases
Testing a Fair Die
A student rolls a six-sided die 120 times and records the frequency of each face, expecting 20 rolls per face if the die is fair. A Goodness of Fit test compares the observed counts to the expected 20-per-face distribution to check whether the die is biased.
Gender and Product Preference
A market researcher surveys 100 customers on whether they like or dislike a product, broken down by gender (40 male / like, 30 female / like, 20 male / dislike, 10 female / dislike). A Test of Independence checks whether preference depends on gender.
Treatment Outcomes Across Hospitals
A medical researcher records recovery outcomes for patients treated at three different hospitals. The Test of Independence determines whether treatment outcome is associated with hospital location, informing whether care quality varies by site.
Website Traffic Source vs. Conversion
A marketing analyst builds a contingency table of traffic source (organic, paid, social) against conversion outcome (converted, did not convert) to test whether conversion behavior differs meaningfully by acquisition channel.
Survey Response Distribution Check
A researcher checks whether Likert-scale survey responses (strongly disagree through strongly agree) follow an expected uniform or theoretical distribution using the Goodness of Fit test before proceeding with further analysis.
Genetics: Observed vs. Expected Ratios
A biology student compares observed offspring phenotype counts against the Mendelian 3:1 expected ratio using a Goodness of Fit test to evaluate whether the cross follows classical inheritance patterns.
Tips & Common Mistakes
Pro Tips
- 💡Watch the low expected frequency warning — if any expected cell is under 5, consider combining categories or using Fisher's exact test instead.
- 💡Use standardized residuals to pinpoint exactly which cells drive a significant Test of Independence result, not just whether the overall test is significant.
- 💡Report Cramér's V alongside the p-value — statistical significance alone doesn't tell you whether an association is practically meaningful, especially with large samples.
- 💡Keep categories mutually exclusive and exhaustive — every observation should fall into exactly one cell of your table.
- 💡For a Goodness of Fit test, make sure your expected counts sum to the same total as your observed counts before interpreting the result.
Common Mistakes to Avoid
- ✕Don't apply a chi-square test to continuous data without first binning it into categories — chi-square tests require categorical counts, not raw measurements.
- ✕Don't use chi-square on percentages or proportions directly — always convert back to raw counts first.
- ✕Don't ignore small expected frequencies — chi-square p-values become unreliable when too many cells have expected counts under 5.
- ✕Don't confuse a significant Test of Independence with causation — an association between two variables doesn't mean one causes the other.
- ✕Don't forget that chi-square tests require independent observations — repeated measurements from the same subject violate this assumption.
Cramér's V Effect Size Reference
| Cramér's V | Association Strength |
|---|---|
| < 0.10 | Negligible |
| 0.10 – 0.19 | Weak |
| 0.20 – 0.39 | Moderate |
| 0.40 – 0.59 | Relatively Strong |
| 0.60 – 0.79 | Strong |
| ≥ 0.80 | Very Strong |
Frequently Asked Questions
What is a chi-square calculator?
A chi-square calculator is a free browser-based tool that performs chi-square hypothesis tests. It supports the Goodness of Fit test, which checks whether observed category counts match expected values, and the Test of Independence, which checks whether two categorical variables in a table are associated.
How is the chi-square statistic calculated?
The chi-square statistic sums, across every category or cell, the squared difference between observed and expected counts divided by the expected count: χ² = Σ ((Observed − Expected)² ÷ Expected). Larger values indicate a bigger mismatch between what was observed and what was expected.
What is a good p-value for a chi-square test?
There's no universally 'good' p-value — it depends on your chosen significance level (commonly 0.05). If the p-value is below your significance level, you reject the null hypothesis; otherwise you fail to reject it. A very small p-value (like 0.001) indicates especially strong evidence against the null hypothesis.
What is the difference between Goodness of Fit and Test of Independence?
Goodness of Fit compares one categorical variable's observed distribution against a specific expected distribution, such as testing whether a die is fair. Test of Independence examines two categorical variables at once, using a contingency table, to determine whether they're related to each other.
How do I calculate degrees of freedom for a chi-square test?
For Goodness of Fit, degrees of freedom equals the number of categories minus 1. For Test of Independence, degrees of freedom equals (number of rows minus 1) times (number of columns minus 1).
What does it mean if my expected frequency is below 5?
The chi-square approximation becomes less reliable when expected cell counts are too small, commonly cited as below 5. The calculator flags this automatically — consider combining sparse categories or using an exact test like Fisher's exact test instead.
What is Cramér's V and why does it matter?
Cramér's V is an effect size measure for the Test of Independence, ranging from 0 (no association) to 1 (perfect association), and it's not affected by sample size the way the chi-square statistic and p-value are. A statistically significant result with a very small Cramér's V may not be practically meaningful.
Can chi-square tests be used on continuous data?
Not directly. Chi-square tests require categorical count data, so continuous measurements must first be grouped into bins or categories before applying either chi-square test.
What do the standardized residuals tell me?
Standardized residuals show, cell by cell, how far the observed count deviates from the expected count in units of standard error. Residuals beyond roughly ±2 highlight the specific cells driving a significant Test of Independence result.
Is my data private when using this calculator?
Yes. All calculations run entirely in your browser using JavaScript. Your data is never transmitted to any server, stored in any database, or accessible to anyone other than you. The calculation history feature saves results only to your browser's local storage, which you can clear at any time.
Who Uses This Calculator?
Students & Teachers
Learn and teach hypothesis testing with instant, verifiable step-by-step calculations.
Researchers & Scientists
Test observed data against expected distributions or check associations between categorical variables.
Business & Data Analysts
Analyze categorical relationships in survey, marketing, and operational data.
Healthcare Professionals
Compare treatment outcomes and patient categories across groups or facilities.
University Professors & Statisticians
Verify manual calculations or generate quick examples for coursework and publications.
Product & Marketing Teams
Test whether user segments behave differently across categorical outcomes.
Related Tools
P-Value Calculator
Calculate p-values and statistical significance for Z-tests, T-tests, Chi-Square tests, F-tests, and correlation tests instantly.
A/B Test Calculator
Analyze A/B test results with a two-proportion z-test — conversion rates, lift, Z-scores, p-values, and statistical significance.
Sample Size Calculator
Calculate the minimum sample size needed for surveys, research studies, and polls with confidence level, margin of error, and finite population correction.
Correlation Coefficient Calculator
Calculate Pearson, Spearman, and Kendall correlation coefficients instantly with scatter plot visualization, regression line, outlier detection, and downloadable reports.
Standard Deviation Calculator
Calculate sample and population standard deviation with variance, quartiles, mode, and histogram/box plot visualization.
Confidence Interval Calculator
Calculate confidence intervals for a mean or proportion, margin of error, and required sample size — with Z and t critical values and formula breakdown.