Truth Table Generator
Type a logical expression and get its full truth table step by step, with the tautology check, minterms and canonical sum of products.
Computed in your browser — nothing is sentGenerate a truth table for any logical expression — step by step
Variables: one letter (p, q, r… or A, B, C…). Operators: ¬ ~ ! NOT · ∧ ^ & AND · ∨ v | + OR · → -> · ↔ <-> · ⊕ XOR · ↑ NAND · ↓ NOR · A' (negation) · AB (implicit AND). ^ is read as AND (∧), as in logic textbooks; use ⊕ for XOR.
How truth tables work
Quick answer: a truth table lists every combination of true and false for the variables in an expression, and the value the expression takes in each one. With n variables there are 2^n rows — 4 for p and q, 8 for p, q and r. Type an expression above with the symbol buttons or plain keys (~ for ¬, & or ^ for ∧, | or v for ∨, -> for →, <-> for ↔), and the table fills in column by column, one column per subexpression, the way it is done by hand.
Under the table it tells you whether the expression is a tautology (true in every row), a contradiction (false in every row) or a contingency. The circuits style shows 1 and 0 in counting order — 000, 001, 010… — plus the minterms and the canonical sum of products, the starting point for simplifying a logic circuit. Primes (A') and juxtaposition (AB for A AND B) work as in digital-logic textbooks, and the copy button pastes the table straight into Excel, Sheets or Word.
Truth tables of the basic connectives
| p | q | ¬p | p ∧ q | p ∨ q | p → q | p ↔ q | p ⊕ q |
|---|---|---|---|---|---|---|---|
| T | T | F | T | T | T | T | F |
| T | F | F | F | T | F | F | T |
| F | T | T | F | T | T | F | T |
| F | F | T | F | F | T | T | F |
Logic gate truth tables (AND, OR, NAND, NOR, XOR, XNOR)
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
NAND and NOR are the complements of AND and OR, and each is universal on its own: every other gate can be built from NAND gates alone (or NOR gates alone). XOR is true when the inputs differ, which is why it is the sum bit of a half adder.
Common mistakes with truth tables
| Mistake | What goes wrong | Fix |
|---|---|---|
| Treating p → q as false when p is false | A conditional is only false in the row p = T, q = F. | Check the p → q column above: three T, one F. |
| Ignoring precedence | ¬p ∧ q means (¬p) ∧ q, not ¬(p ∧ q); ∧ binds tighter than ∨, and → is weaker than both. | Add parentheses whenever in doubt. |
| Reading ∨ as “one or the other, not both” | The logical OR is inclusive: true when both are true. | Use ⊕ (XOR) for the exclusive or. |
| Using ^ for XOR, as in programming | In logic textbooks ^ is typed for ∧; this tool reads it as AND. | Write ⊕ or XOR for exclusive or. |
Reference tables
FAQ
How many rows does a truth table have?
2^n, where n is the number of variables: 2 variables give 4 rows, 3 give 8, 4 give 16. This generator handles up to 8 variables (256 rows).
What is the truth table of p → q?
It is false in exactly one row: p true and q false. In the other three rows it is true — including both rows where p is false, because a conditional with a false premise is true (vacuously).
What is the difference between a tautology and a contingency?
A tautology is true in every row (p ∨ ¬p), a contradiction is false in every row (p ∧ ¬p), and a contingency is true in some rows and false in others (p → q). A biconditional that is a tautology proves two expressions are equivalent.