Chi-Square Test
Online Chi-Square Test Calculator
A free browser-based chi-square calculator for categorical data. Run a goodness-of-fit test against expected proportions, or a test of independence on a contingency table. Output includes chi-squared, degrees of freedom, p-value and Cramer's V effect size.
Open the calculator
Run this analysis in the DeepStats analyzer. Free, no sign-up required, results appear instantly after you paste or upload data.
Open the calculator — run it in /analyzeWhen to use this test
- •You have one categorical variable and want to check whether it follows a specified distribution (goodness-of-fit).
- •You have two categorical variables and want to know whether they are independent (test of independence).
- •Your observations fall naturally into counts or frequencies, not continuous measurements.
- •Each observation is classified into exactly one cell of your table — no overlap between categories.
- •You have at least ~5 expected observations per cell (otherwise use Fisher's exact test instead).
How to use it
- 1
Upload or paste raw or summarised data
Two input formats work. Long format: one row per observation, with categorical columns for each variable. Summary format: a contingency table where rows and columns are categories and cells are counts. The analyzer accepts either.
- 2
Pick the chi-square variant
In Hypothesis Tests choose Chi-square goodness-of-fit (one categorical variable against expected proportions) or Chi-square test of independence (two categorical variables in a contingency table).
- 3
Assign variables
For goodness-of-fit, drag your single categorical column into the Category slot and enter expected proportions (equal, uniform or custom). For independence, drag one variable into Row and the other into Column.
- 4
Inspect the contingency table and result
DeepStats builds the observed and expected frequency tables, highlights cells that deviate most, and returns chi-squared, degrees of freedom, p-value and Cramer's V. A mosaic plot shows the pattern visually.
- 5
Export or follow up
Download the tables as CSV and the mosaic plot as PNG. If cells are sparse, the analyzer offers Fisher's exact test as a drop-in alternative.
Example with sample data
A simple test of independence between smoking status and lung condition, eight observations aggregated into a 2x2 table. Paste the raw rows below into the analyzer.
Smoker,Condition
Yes,Ill
Yes,Ill
Yes,Healthy
Yes,Ill
No,Healthy
No,Healthy
No,Ill
No,HealthyWith this tiny dataset the analyzer reports chi-squared ≈ 2.0, df = 1, p ≈ 0.157 and Cramer's V ≈ 0.5. You would fail to reject the null hypothesis at alpha = 0.05. Because cell counts are small, DeepStats also suggests Fisher's exact test as the safer alternative.
How to interpret the results
You will see: chi-squared statistic, degrees of freedom, p-value, Cramer's V (effect size), observed and expected frequency tables.
- Chi-squared statistic
- Computed as χ² = Σ (O − E)² / E, summed over every cell. O is the observed count and E is the expected count under the null hypothesis. Big differences in any cell push χ² up.
- Degrees of freedom (df)
- For goodness-of-fit, df = k − 1 where k is the number of categories. For a contingency table of r rows and c columns, df = (r − 1)(c − 1). The df determines which chi-squared distribution is used for the p-value.
- p-value
- The probability of observing a χ² at least as extreme as yours if the null were true. Below 0.05 indicates a significant deviation from the expected pattern. In a test of independence, a small p-value says the two variables are associated.
- Cramer's V
- Standardised effect size scaled from 0 (no association) to 1 (perfect). Rough benchmarks for a df of 1: 0.1 small, 0.3 medium, 0.5 large. Cramer's V is essential alongside the p-value because chi-squared grows with sample size and can flag trivially small associations in big datasets.
- Observed vs expected table
- The analyzer displays the expected frequencies under the null hypothesis. Cells where observed minus expected is large indicate which categories drive the result — a useful diagnostic for writing up your finding.
Assumptions
- Independent observations.Each count should come from a different subject or event. Repeated measurements on the same person violate the assumption. Use McNemar's test for paired 2x2 designs instead.
- Expected counts of at least 5 per cell.When more than 20% of cells have an expected count below 5, the chi-squared approximation breaks down. Switch to Fisher's exact test or collapse sparse categories before re-running.
- Fixed categories.Categories must be mutually exclusive and exhaustive. An observation cannot belong to two categories or to none.
- Random sampling.The data should be a random sample of the population you want to generalise to. Convenience samples may still be informative but limit external validity.
Related calculators
Frequently asked questions
Is this chi-square calculator free?+
Yes. Running chi-square goodness-of-fit and independence tests is free with no account, and you can upload as many datasets as you like.
What is the difference between chi-square and Fisher's exact test?+
Chi-square uses an approximation that works well when cell counts are reasonably large. Fisher's exact test computes the exact p-value directly and is preferred when any expected count is below 5. DeepStats offers both side by side.
Can I use chi-square on continuous data?+
Not directly — chi-square is for counts and proportions. To use it on a continuous variable you would first need to bin it into categories, which throws away information. A t-test or regression is usually the right choice for continuous data.
Do I need raw data or can I enter a summary table?+
Both are supported. Paste raw rows with categorical columns and the analyzer builds the contingency table, or paste a ready-made table of counts and skip the tabulation step.
Why is my large-sample result significant but uninteresting?+
Chi-squared grows with sample size, so in datasets with tens of thousands of rows even trivially small deviations become statistically significant. That is why Cramer's V is reported — always read the effect size alongside the p-value before drawing substantive conclusions.