Skip to content
tools.best

Browse all tools

Truth Table Generator

Type a logical expression with up to 10 variables and get every row of its truth table, plus whether it is a tautology, a contradiction or contingent.

Runs in your browser. Nothing you enter is sent to a server. Sources: IEP Updated

One letter per variable. Example: (A && B) || !C -> D

Logic operators the truth table generator accepts

OperatorType it asThe result is true when
NOT! ~ ¬ notthe part after it is false
AND&& & ∧ andboth sides are true
XOR^ ⊕ xorexactly one side is true
OR|| | ∨ orat least one side is true
IMPLIES-> => → impliesalways, except when the left side is true and the right side is false
IFF<-> <=> ↔ iffboth sides have the same value

Variables are single letters from A to Z. Capitals and lowercase are the same variable. Note that ^ means XOR here, as it does in C, Java, JavaScript and Python. For AND use && or ∧.

Truth tables of the five two-variable operators for A and B: AND is true only when both are true, OR is false only when both are false, XOR is true when exactly one is true, IMPLIES is false only for A true and B false, and IFF is true when both have the same value.
OR and XOR differ only in the first row, where both sides are true.

Order of operations: NOT, AND, XOR, OR, IMPLIES, IFF

Parentheses are worked out first. After that the tool applies NOT, then AND, then XOR, then OR, then IMPLIES, and IFF last. The table above is in that order.

Two operators of the same kind are grouped from the left, with one exception: IMPLIES is grouped from the right, so A -> B -> C is read as A → (B → C).

This order is the rule this tool uses. Textbooks and programming languages do not all agree on one, and many logic texts expect you to write the parentheses yourself.

So when you copy an expression from a book, keep its parentheses, and check the "Read as" line under the buttons. It repeats your expression with every group written out.

Truth table example: (A or B) implies C

Enter (A || B) -> C. There are three variables, so the table has 2 × 2 × 2 = 8 rows:

ABC(A ∨ B) → C
TTTT
TTFF
TFTT
TFFF
FTTT
FTFF
FFTT
FFFT

The expression is false in the three rows where A or B is true but C is false. In the last row both A and B are false, so the left side is false and the conditional is true. The tool reports "True in 5 of 8 rows. It is contingent: true in some rows and false in others."

Tautology, contradiction or contingent: how to tell

  • A tautology is true in every row. Try A || !A.
  • A contradiction is false in every row. Try A && !A.
  • Everything else is contingent: true in some rows and false in others.

Two expressions are equivalent when they have the same value in every row. To test that, join them with <->. For example !(A && B) <-> (!A || !B), one of De Morgan's laws, comes out as a tautology.

How many rows a truth table has

Each variable can be true or false, so n variables give 2ⁿ rows.

VariablesRows
12
24
38
416
532
664
8256
101,024

With "T and F" the first row has every variable true and the last row has every variable false. With "1 and 0" the rows count upward in binary from 0 (000, 001, 010 and so on). "Copy table" copies the table as tab-separated text, which pastes into a spreadsheet as separate columns.

The "1 and 0" rows are the binary numbers from 0 upward, the same notation text to binary uses for bytes. To print a table in a paper, type its rows into the LaTeX table generator. More tools for code and data are under developer tools.

Truth Table Generator: FAQ

Why is A -> B true when A is false?
That is how the conditional is defined in propositional logic: A -> B is false in exactly one case, when A is true and B is false. Think of a promise such as "if it rains, I will bring an umbrella". It is only broken on a day when it rains and there is no umbrella. On a dry day the promise is kept whatever happens.
What is the difference between OR and XOR?
OR is true when at least one side is true, so it is also true when both are. XOR is true when exactly one side is true. The two tables differ in a single row, the one where both sides are true: OR gives true there and XOR gives false.
How do I check that two expressions are equivalent?
Join them with iff and put each one in parentheses, for example (not (A and B)) iff (not A or not B). If the result says tautology, the two expressions have the same value in every row, which is what equivalent means.
Can I use lowercase letters or longer names?
Lowercase letters work and count as the same variable as the capital, so a and A are one variable. Names longer than one letter are not accepted, because the words AND, OR, NOT, XOR, IMPLIES and IFF are read as operators. Use one letter for each statement.
Why is there a limit of 10 variables?
Every extra variable doubles the table. Ten variables already give 1,024 rows. The limit is a choice made for this tool to keep the table readable; it is not a limit of logic.

Sources