TapCub is live — analytics, insights and live chat, free on one platform

Free tool Chi-square calculator and chi-square formula

Do conversion rates really differ by channel? Does traffic really spread evenly across weekdays? Type or paste the counts. You get χ², the p-value, the expected count in every cell and an effect size, plus a warning when the table is too sparse for the test to be trusted.

  • Independence and goodness of fit
  • Flags expected counts under 5
  • Runs locally
Calculator

Enter the counts

Each cell is a count of people, sessions or orders, never a percentage or an average. Rename rows and columns so the results table is easy to read.

Independence: are two categorical variables related? Goodness of fit: do counts match the proportions you expected?

Total
1,000
800
800
Total1822,4182,600

Tip: copy a block of cells from Excel or Google Sheets and paste it into any cell. The table resizes, and a first row or column of text becomes the labels.

Significant at α = 0.05 (p = 0.0055): the two variables are associated. The cells with large residuals show where.

Chi-square (χ²)

10.422

p-value

0.0055

Degrees of freedom

2

Total count (N)

2,600

Critical value (α = 0.05)

5.991

χ² above this is significant.

Cramér’s V

0.063

0 = no association, 1 = perfect.

Observed, expected and residuals

Each cell: observed count, expected count (E) under no relationship or the expected ratio, and the standardized residual (r; adjusted residual for independence tests). |r| ≥ 1.96 marks the cells that drive the result; E under 5 is highlighted.

Signed upDid not
Organic search84E 70r 2.21916E 930r −2.21
Paid search61E 56r 0.83739E 744r −0.83
Social37E 56r −3.16763E 744r 3.16
Report line
χ²(2, N = 2600) = 10.42, p = 0.005, Cramér's V = 0.063
Runs entirely in your browser. Nothing you type here is uploaded or stored by TapCub.

Share these inputs: the values go after the # in the link, so they never reach a server.

Version v1.0Updated Update history

Reading the result

Is there a relationship, and where?

The example asks whether sign-up rate depends on traffic source: 8.4% from organic search, 7.6% from paid, 4.6% from social.

χ² and p-value

χ² adds up how far every observed count is from what you would expect if source and sign-up were unrelated. Here χ² = 10.42 with 2 degrees of freedom, p = 0.0055: a gap this large would be rare by chance. The test does not say which source differs.

Expected counts

If sign-up were unrelated to source, 7% of each source (182 of 2,600) would sign up: 70 from organic, 56 from paid, 56 from social. Every expected count should be at least 5 for the p-value to be reliable; the calculator warns you when it is not.

Standardized residuals

They show which cells drive the result. Social has 37 sign-ups against 56 expected, r = −3.16; organic has 84 against 70, r = +2.21. Cells beyond ±1.96 are where the association lives.

Cramér’s V

An effect size from 0 to 1 that ignores sample size: 0.063 here, a weak association even though it is significant. With thousands of rows almost any difference becomes significant, so read V before acting.

Chi-square shows association, not cause. Social visitors may sign up less because of who they are, which page they land on, or when they arrive. Segment further before concluding.

How to use it

Build the table, then read the cells

The calculator updates as you type. Use the buttons to add or remove rows and columns, up to 6 × 6.

  1. 1

    Choose the test

    Two categorical variables measured on the same people (channel × converted, plan × churned): test of independence. One variable against known or planned proportions (traffic split, weekday mix): goodness of fit.

  2. 2

    Enter or paste counts

    Type counts into the cells, or paste a block from a spreadsheet. Each person must appear in exactly one cell. Rename rows and columns so the residual table reads clearly.

  3. 3

    Check the warnings, then the residuals

    If any expected count is under 5, follow the advice shown. If the result is significant, the standardized residuals tell you which cells are higher or lower than expected.

Chi-square formula

Observed minus expected, squared, scaled

For every cell, the expected count is what the margins alone would predict. χ² sums the squared gaps between observed and expected, each divided by the expected count, and the p-value comes from the chi-square distribution with the right degrees of freedom.

  • Expected count: row total × column total ÷ grand total (independence) or N × expected share (goodness of fit)
  • Degrees of freedom: (rows − 1) × (columns − 1) for independence; categories − 1 for goodness of fit
  • Yates correction subtracts 0.5 from each |O − E| before squaring (2 × 2 only, never more than |O − E|)
  • Fisher’s exact test sums the hypergeometric probabilities of every table at least as extreme, with no approximation
  • Rule of thumb (Cochran): all expected counts ≥ 1 and at most 20% under 5

Chi-square statistic

χ² = Σ (O − E)² ÷ E, E = row total × column total ÷ N

Example: χ² = 10.42, df = (3 − 1) × (2 − 1) = 2, p = 0.0055

2 × 2 shortcut

χ² = N(ad − bc)² ÷ [(a + b)(c + d)(a + c)(b + d)]

With Yates: replace (ad − bc)² by (|ad − bc| − N/2)²

Effect size and residuals

V = √( χ² ÷ (N × (min(r, c) − 1)) ) r = (O − E) ÷ √(E(1 − row/N)(1 − col/N))

For a 2 × 2 table V equals |φ|

Worked example

An A/B test as a 2 × 2 table

Version A converted 42 of 400 visitors, version B 63 of 400. Rows: versions; columns: converted / not. Grand total N = 800, 105 conversions in all, so each version is expected to convert 105 × 400 ÷ 800 = 52.5.

Chi-square for a 2 × 2 table by hand
CellObserved OExpected E(O − E)² ÷ E
A · converted4252.52.100
A · not converted358347.50.317
B · converted6352.52.100
B · not converted337347.50.317
χ² (df = 1)4.835, p = 0.0279
Yates-corrected4.385, p = 0.0363
Fisher’s exactp = 0.0359

Shortcut: 800 × (42 × 337 − 358 × 63)² ÷ (400 × 400 × 105 × 695) = 4.835. All three methods agree at α = 0.05 here. With a small table such as 8 / 2 vs 3 / 7, plain χ² gives p = 0.025 while Yates (0.072) and Fisher (0.070) do not. Example data.

Common mistakes

Where chi-square tests go wrong

The test is simple and robust, provided the table is built correctly.

Entering percentages instead of counts

8.4% and 91.6% look like data but carry no sample size. χ² depends on the counts: 84 / 916 and 8 / 92 have the same percentages and very different p-values.

Counting the same person twice

Every observation must fall in exactly one cell. Page views from returning visitors, or people who chose several answers, break the independence the test relies on.

Ignoring small expected counts

With expected counts under 5 the chi-square distribution is a poor approximation and p-values can be far too small. Merge categories, collect more data, or use Fisher’s exact test.

Reading significance as strength

With large samples a trivial difference becomes significant. Check Cramér’s V and the residuals to see whether the association is big enough to matter.

FAQ

Chi-square questions

Still have a question?

Chat with the team behind TapCub — we usually reply within a few hours on business days.

What does a chi-square test tell you?

Whether the pattern of counts in a table is likely to be chance. The test of independence asks whether two categorical variables are related; the goodness-of-fit test asks whether one variable follows expected proportions. A small p-value means the observed counts are far from what no relationship (or the expected ratio) would produce.

What is the chi-square formula, and how do I calculate it?

χ² = Σ (O − E)² ÷ E over every cell, where O is the observed count and E = row total × column total ÷ N. For a 2 × 2 table there is a shortcut: χ² = N(ad − bc)² ÷ [(a + b)(c + d)(a + c)(b + d)], with one degree of freedom. For 42 / 358 and 63 / 337: χ² = 4.835, p = 0.028.

When should I use the Yates correction or Fisher’s exact test?

Both are for 2 × 2 tables with small counts. Yates makes the chi-square test more conservative; Fisher’s exact test needs no approximation at all and is the safer choice when any expected count is under 5. With large counts all three give nearly the same answer.

What if expected counts are below 5?

The common rule (Cochran, 1954) allows up to 20% of cells under 5 and none under 1. Beyond that, merge sparse categories, collect more data, or use an exact test. The calculator counts the cells and warns you.

How are degrees of freedom calculated?

For a contingency table: (rows − 1) × (columns − 1), so 1 for a 2 × 2 table and 2 for a 3 × 2 table. For goodness of fit: number of categories − 1. They set which chi-square distribution the p-value comes from.

Chi-square or t-test?

Chi-square compares counts of categories (converted or not, which plan). A t-test compares averages of measured values (order value, time on task). A conversion-rate A/B test can use either chi-square on the 2 × 2 table or a two-proportion z-test; without correction they give the same p-value.

Can I use it to check an A/B traffic split?

Yes: goodness of fit with the planned split as the expected ratio. A significant result there is a sample ratio mismatch. The SRM checker is built for exactly that check.

Changelog

Update history

New features, fixes and data refreshes for this tool, newest first.

  1. · v1.0

    LaunchedFirst release.

Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates

Next step

From association to a decision

A significant table tells you something differs. Check the size of the difference, and plan the sample for the next test before it starts.

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics