Truth table generator
Type a logical statement and get its full truth table, with a column for every step, in T and F or 1 and 0. It tells you if the statement is a tautology, a contradiction or a contingency, and whether two statements are equivalent.
Examples:
Simplified form, minterms and maxterms
Step-by-step simplification
Runs in your browser. Nothing you type is uploaded.
How to use the truth table generator
- Type a statement, for example
p → qor(p ∨ q) ∧ ¬p → q. The buttons under the box insert ¬, ∧, ∨, → and ↔, and you can also type~,&,|,->and<->. - Read the table. Every variable gets a column, every sub-expression gets a column in the order you would work it out by hand, and the shaded column on the right is the whole statement.
- Read the line above the table. It says whether the statement is a tautology (always true), a contradiction (always false) or a contingency (true in some rows).
- Change the display if your course does it differently: T and F or 1 and 0, rows starting with all false or all true, every step or only the result.
- Copy the table as CSV for a spreadsheet, Markdown for notes or a README, or LaTeX for an assignment.
To compare statements, separate them with commas: p → q, ¬q → ¬p builds one table with a result column for each, and tells you whether they are equivalent. To shorten a statement instead, use the Boolean algebra calculator, which shows each law it applies.
How to type a logical expression
| Connective | Symbol | Also accepted | True when |
|---|---|---|---|
| Negation (not) | ¬p | ~p !p p' NOT p | p is false |
| Conjunction (and) | p ∧ q | p & q p * q pq p AND q | both are true |
| Disjunction (or) | p ∨ q | p | q p + q p OR q | at least one is true |
| Exclusive or | p ⊕ q | p ^ q p XOR q | exactly one is true |
| Conditional (implies) | p → q | p -> q p => q p ⊃ q | p is false, or q is true |
| Biconditional (iff) | p ↔ q | p <-> q p <=> q p == q p ≡ q | both have the same value |
| NAND, NOR | p ↑ q p ↓ q | p NAND q p NOR q | not both true / neither true |
| Constants | T F | 1 0 ⊤ ⊥ | always / never |
Variables are letters with optional digits, such as p, q2 or A. Capital T and F are the constants true and false, so pick other letters for variables. Up to 8 variables are supported, which is a 256-row table.
Without brackets, ¬ binds tightest, then ∧, then ⊕, then ∨, then →, then ↔. So p ∨ q ∧ r means p ∨ (q ∧ r), and p ∧ q → r means (p ∧ q) → r. A chain of arrows groups from the right: p → q → r is p → (q → r). Column headers in the table show the brackets the generator used, so you can see how it read your input.
Worked example: the truth table for p → q
The conditional confuses more people than any other connective, so it is worth building by hand once. Two variables give 2 × 2 = 4 rows. List every combination of p and q, then fill in p → q.
| p | q | p → q |
|---|---|---|
| T | T | T |
| T | F | F |
| F | T | T |
| F | F | T |
Read the second row first: p is true and q is false. That is the only way to break the promise "if p, then q", so it is the only false row. When p is false (rows 3 and 4) the statement makes no claim at all, and logic counts an unbroken promise as true. Think of "if it rains, I'll take an umbrella": on a dry day, nothing you do makes that sentence a lie.
This table starts with T, as most logic textbooks do. The generator starts with F, the way digital electronics books put 0 0 at the top, so switch "Rows" to T first to match the layout here. The rows are the same, in the opposite order.
Reading a table with intermediate columns
Longer statements are built from smaller ones, and the generator gives each smaller piece its own column so you can follow the work. Here is the default example, (p → q) ∧ (q → r) → (p → r), which says that if p leads to q and q leads to r, then p leads to r.
| p | q | r | p → q | q → r | (p → q) ∧ (q → r) | p → r | ((p → q) ∧ (q → r)) → (p → r) |
|---|---|---|---|---|---|---|---|
| T | T | T | T | T | T | T | T |
| T | T | F | T | F | F | F | T |
| T | F | T | F | T | F | T | T |
| T | F | F | F | T | F | F | T |
| F | T | T | T | T | T | T | T |
| F | T | F | T | F | F | T | T |
| F | F | T | T | T | T | T | T |
| F | F | F | T | T | T | T | T |
Work left to right. The ∧ column is true only where both arrow columns are true. The last column is false only where the ∧ column is true and p → r is false, and that never happens, so every entry is T. The statement is a tautology. Logic courses call this rule hypothetical syllogism.
With 3 variables you get 23 = 8 rows. Each extra variable doubles the table, which is why 4 variables give 16 rows and 8 give 256. The # column gives each row its number in binary counting order, so the row numbered 5 is p = T, q = F, r = T, the binary number 101, whichever row order you pick.
Tautology, contradiction or contingency
Every statement falls into one of three groups, and the label above the table tells you which.
- A tautology is true in every row, such as
p ∨ ¬por the syllogism above. A valid argument turned into a single "premises → conclusion" statement is a tautology. - A contradiction is false in every row, such as
p ∧ ¬p. If the premises of an argument form a contradiction, they can never all be true at once. - A contingency is true in some rows and false in others, such as
p → q. Most statements are contingent.
To test whether an argument is valid, join its premises with ∧, put → before the conclusion and check for a tautology. For example, (p ∨ q) ∧ ¬p → q (disjunctive syllogism) comes out as a tautology, so the argument is valid.
Check whether two statements are equivalent
Two statements are logically equivalent when their result columns match in every row. Type them separated by a comma. p → q, ¬q → ¬p gives two identical columns: a conditional and its contrapositive always agree. p → q, q → p does not, because the converse is false where p is false and q is true.
| p | q | p → q | ¬q → ¬p | q → p |
|---|---|---|---|---|
| T | T | T | T | T |
| T | F | F | F | T |
| F | T | T | T | F |
| F | F | T | T | T |
The same check proves De Morgan's laws: ¬(p ∧ q), ¬p ∨ ¬q gives matching columns. The De Morgan's law guide shows the same pair as logic gates.
Truth tables for logic gates
Digital electronics uses the same tables with 1 and 0 instead of T and F, and gate names instead of logic symbols. Switch "Notation" to Algebra and "Values" to 1 and 0, then type A NAND B, A NOR B, A ⊕ B to get the tables for three gates side by side.
| A | B | A NAND B | A NOR B | A ⊕ B |
|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 0 |
In algebra notation A'B + AB' means (NOT A AND B) OR (A AND NOT B), which is the XOR table above. Every gate, with its symbol, is covered in the logic gates guide, and when a gate table gets too large to read, a Karnaugh map turns it into the smallest two-level (sum of products) circuit.
Mistakes that give the wrong table
Reading → as "causes". p → q is true whenever p is false, even when p and q have nothing to do with each other. If your table has F in the rows where p is false, you have built a different connective.
Negating one variable instead of the group. ¬p ∧ q means (not p) and q. ¬(p ∧ q) means not (p and q). They differ in two of four rows. The generator shows the brackets it used in the column header, so compare that header with what you meant.
Swapping → and ↔. "p if and only if q" is p ↔ q, true when p and q match. "If p then q" is p → q. Their tables differ in the row where p is false and q is true.
Comparing tables with a different row order. Some books start with all true, others with all false. If your answer looks wrong, switch "Rows" before you go looking for an error.
Frequently asked questions
How do you make a truth table?
Count the variables and make 2n rows, listing every true and false combination. Add a column for each sub-expression, working from the innermost brackets outward, and finish with a column for the whole statement.
How many rows does a truth table have?
2n for n variables: 4 rows for 2 variables, 8 for 3, 16 for 4 and 256 for 8. This generator handles up to 8 variables.
What does the arrow mean in a truth table?
p → q is the conditional, "if p then q". It is false only when p is true and q is false, and true in the other three rows.
How do I know if a statement is a tautology?
Build its truth table. If the final column is true in every row, it is a tautology. The generator labels this for you above the table.
Can I generate a truth table for several statements at once?
Yes. Separate them with commas. You get one table with a shaded result column for each statement, and a note saying which are equivalent to the first.
Can I get the Boolean expression from a truth table?
Yes, the "Simplified form, minterms and maxterms" panel gives the shortest sum of products and product of sums for the first result column, plus, for up to 4 variables, the canonical forms that list one term per row.
Who invented truth tables?
They appeared in their modern form around 1921, in Ludwig Wittgenstein's Tractatus Logico-Philosophicus and in Emil Post's work on propositional logic, although Charles Peirce had used the idea in unpublished notes in the 1890s.

