Updated on April 18th, 2026

Chi Square Calculator

Created By Jehan Wadia

# Category Label Observed (O) Expected (E)

Results: Goodness-of-Fit Test
CategoryOEO − E(O − E)²(O − E)² / E
Chi-Square (χ²)
Degrees of Freedom
P-Value
Critical Value
Significant?

Results: Test of Independence

Expected Frequencies

Chi-Square Contributions: (O − E)² / E

Chi-Square (χ²)
Degrees of Freedom
P-Value
Critical Value
Significant?

Results: χ² / P-Value Lookup
P-Value
Critical Value
χ² Statistic
Significant?

Introduction

The Chi Square Calculator helps you find out if there is a real connection between two sets of data. In statistics, a chi-square test compares what you expect to happen with what actually happens. If the numbers are very different, it might mean something important is going on — not just random chance. Scientists, students, and researchers use this test all the time to check their ideas and draw conclusions from data.

To use this calculator, just enter your observed and expected values. The tool will do the math for you and give you the chi-square statistic, degrees of freedom, and the p-value. The p-value tells you how likely it is that the difference in your data happened by chance. A small p-value (usually less than 0.05) means the result is statistically significant. You can also use our dedicated p-value calculator for a deeper look at significance testing. This calculator saves you time and removes the chance of making errors when doing the formula by hand.

How to Use Our Chi Square Calculator

Enter your observed and expected data to calculate the chi-square statistic, p-value, degrees of freedom, and whether your result is statistically significant. This calculator has three modes: Goodness-of-Fit, Test of Independence, and a χ²/P-Value lookup.

Goodness-of-Fit Tab: Use this mode when you want to test if your observed data matches an expected pattern. Toggle the "Use equal expected frequencies" switch if you expect each category to have the same count. If not, enter your own expected values for each category.

Category Label: Type a name for each category so you can tell your groups apart in the results table.

Observed (O): Enter the actual count you recorded for each category. These must be whole numbers zero or greater.

Expected (E): Enter the count you expected for each category based on your hypothesis. If the equal expected switch is on, these fill in automatically by splitting the total evenly across all categories.

Add Category / Remove Category: Click "Add Category" to include more groups in your test, up to 30. Click the red X button next to any row to remove a category. You must keep at least two categories.

Independence Tab: Use this mode when you have a contingency table and want to test whether two categorical variables are related. Set the number of rows and columns for your table, then click "Build Table" to create the grid.

Number of Rows and Number of Columns: Enter how many rows and columns your contingency table has. Each must be at least 2 and no more than 15. After changing these values, click "Build Table" to update the grid.

Contingency Table Cells: Enter the observed count for each cell in the table. The calculator will figure out the expected frequencies, chi-square contributions, row totals, and column totals for you.

χ² / P-Value Tab: Use this mode when you already know your chi-square statistic and degrees of freedom and just need the p-value, critical value, and a visual chart of the chi-square distribution.

Chi-Square Statistic (χ²): Enter the chi-square value you have already calculated. This must be zero or greater.

Degrees of Freedom (df): Enter the degrees of freedom for your test. This must be a whole number of 1 or more. For a goodness-of-fit test, df equals the number of categories minus one. For a test of independence, df equals (rows minus one) times (columns minus one).

Significance Level (α): Available on all three tabs, this sets the threshold for deciding if your result is significant. Choose a common value like 0.05 from the dropdown, or select "Custom" and type in your own value between 0.0001 and 0.9999.

What Is a Chi-Square Test?

A chi-square (χ²) test is a statistical method used to compare what you observe in real data to what you would expect to see if nothing special were happening. In simple terms, it helps you decide whether the differences between your data and your expectations are big enough to matter, or if they could just be due to random chance.

Types of Chi-Square Tests

There are two main types of chi-square tests, and this calculator handles both:

Goodness-of-Fit Test

The goodness-of-fit test checks whether data from one variable matches an expected pattern. For example, imagine you roll a die 120 times. You would expect each number (1 through 6) to show up about 20 times. If your actual results look very different from that, the goodness-of-fit test can tell you whether the die might be unfair or if your results are within the range of normal luck. You compare observed counts to expected counts across several categories, and the test produces a single χ² value that summarizes how far off your data is overall.

Test of Independence

The test of independence checks whether two variables are related to each other. You organize your data into a table with rows and columns, called a contingency table. For instance, you might want to know if a student's grade level is related to their favorite school subject. The test calculates what the numbers in each cell would look like if the two variables had no connection at all, then measures how much the real numbers differ from those expected values.

How the Chi-Square Formula Works

Both tests use the same core formula: for each category or cell, you subtract the expected value (E) from the observed value (O), square the result, and then divide by the expected value. You then add up all of these pieces. Written out, the formula is χ² = Σ [(O − E)² / E]. A larger χ² value means your data differs more from what was expected.

Key Terms

When to Use a Chi-Square Test

Chi-square tests work with categorical data — data sorted into groups or categories, not measured on a number line. Common examples include survey responses, color preferences, yes/no outcomes, and demographic groups. The test requires that each expected frequency is reasonably large (a common rule of thumb is at least 5) so that the results are reliable.

Reading Your Results

After calculating, look at the p-value and compare it to your chosen significance level. If the p-value is smaller, you have enough evidence to say the difference is statistically significant. If the p-value is larger, you do not have enough evidence to claim a real difference exists. The χ²/P-Value tab in this calculator also lets you enter a chi-square statistic and degrees of freedom directly, which is useful when you already have a χ² value from another source and just need the corresponding p-value or want to visualize where it falls on the chi-square distribution curve.

When analyzing your data further, you may find it helpful to explore related statistical tools. Our Z score calculator is useful for understanding how individual data points relate to the mean of a distribution, while the standard deviation calculator helps you measure the spread of your dataset. If you need to check how closely two variables move together, the correlation coefficient calculator is a great complement to the independence test. For summarizing your data before running a chi-square test, our mean median mode calculator can help you understand central tendency, and the IQR calculator is handy for identifying outliers. If your analysis involves percent error or percent change, those tools can round out your statistical toolkit. For probability-related work involving arrangements of categories, you might also explore our combination calculator and permutation calculator.


Frequently Asked Questions

What is a good chi-square value?

There is no single "good" chi-square value. What matters is how your chi-square value compares to the critical value for your degrees of freedom and significance level. If your chi-square is larger than the critical value, the result is statistically significant. A chi-square of zero means your observed data perfectly matches the expected data. The bigger the chi-square, the more your data differs from what was expected.

What happens if my expected frequency is less than 5?

The chi-square test works best when every expected frequency is at least 5. If some expected values are below 5, the test may not give reliable results. In that case, you can try combining small categories together to raise the expected counts, or use a different test like Fisher's exact test for small samples.

Can I use decimals for observed values?

Observed values should normally be whole numbers because they represent actual counts of things you measured or recorded. The calculator will accept decimals, but in most real situations your observed data should be integers like 10, 25, or 42.

What does it mean when the p-value is very small?

A very small p-value means there is very little chance that the difference between your observed and expected data happened by random luck. For example, a p-value of 0.002 means there is only a 0.2% chance of seeing results this extreme if nothing special were going on. This is strong evidence that something real is causing the difference.

What significance level should I use?

The most common significance level is 0.05, which means you accept a 5% chance of being wrong when you say the result is significant. Use 0.01 if you need to be more strict, like in medical research. Use 0.10 if you are doing an early or exploratory study and want to catch possible patterns even if they are less certain.

What is the difference between the goodness-of-fit test and the test of independence?

The goodness-of-fit test looks at one variable and checks if your data matches an expected pattern. The test of independence looks at two variables and checks if they are related to each other. Use goodness-of-fit when you have one list of categories. Use independence when you have a table with rows and columns representing two different variables.

How do I calculate degrees of freedom?

For a goodness-of-fit test, degrees of freedom equals the number of categories minus 1. If you have 5 categories, df = 4. For a test of independence, degrees of freedom equals (number of rows minus 1) times (number of columns minus 1). A 3×4 table has df = (3−1) × (4−1) = 6.

Why is my chi-square value zero?

A chi-square value of zero means your observed data exactly matches your expected data in every category. Every observed count equals its expected count, so there is no difference at all. This is rare in real data but can happen if you accidentally entered the same numbers for both observed and expected values.

Can I use this calculator for a 2x2 contingency table?

Yes. Set the number of rows to 2 and columns to 2 in the Independence tab, click "Build Table," and enter your four observed counts. The calculator will compute the expected values, chi-square statistic, and p-value for you. For very small sample sizes in a 2×2 table, consider using Fisher's exact test instead.

What does the highlighted row in the results mean?

The highlighted row shows the category or cell that contributes the most to the overall chi-square value. This tells you which category has the biggest gap between what was observed and what was expected. It helps you quickly spot where the largest difference in your data is coming from.

What is the critical value?

The critical value is the chi-square number that marks the cutoff point for your test. If your calculated chi-square is greater than the critical value, you reject the null hypothesis and say the result is significant. The critical value depends on your degrees of freedom and your chosen significance level (α).

Can chi-square values be negative?

No. Chi-square values can never be negative. The formula squares the difference between observed and expected values, so every piece of the calculation is zero or positive. If you get a negative number, there is an error in your input or calculation.

What does 'fail to reject the null hypothesis' mean?

It means your data does not show a big enough difference to conclude that something special is happening. It does not mean the null hypothesis is true — it just means you do not have strong enough evidence to say it is false. Your observed data is close enough to the expected data that the difference could be due to chance.

How many categories can I add in the goodness-of-fit test?

You can add up to 30 categories in the goodness-of-fit test. You must keep at least 2 categories. Click the "Add Category" button to add more rows, and click the red X button to remove a row you do not need.

What does the χ² / P-Value tab do?

This tab is a quick lookup tool. If you already know your chi-square statistic and degrees of freedom from another source, enter them here to get the p-value, critical value, and a visual chart showing where your value falls on the chi-square distribution. You do not need to enter raw data for this tab.

Does the chi-square test show how strong a relationship is?

No. The chi-square test only tells you whether a relationship or difference exists — not how strong it is. To measure the strength of a relationship, you would need additional measures like Cramér's V or the phi coefficient, which build on the chi-square result.


Related Calculators

Percent Error Calculator

Visit Percent Error Calculator

Percent Change Calculator

Visit Percent Change Calculator

Percentage Calculator

Visit Percentage Calculator

IQR Calculator

Visit IQR Calculator

Z Score Calculator

Visit Z Score Calculator

Standard Deviation Calculator

Visit Standard Deviation Calculator

Mean Median Mode Calculator

Visit Mean Median Mode Calculator

Correlation Coefficient Calculator

Visit Correlation Coefficient Calculator

p Value Calculator

Visit p Value Calculator

Confidence Interval Calculator

Visit Confidence Interval Calculator

Sample Size Calculator

Visit Sample Size Calculator