Truth Table Generator
Type an expression and get every row of its truth table, or leave the box empty and have one drawn for you. Whatever you type is echoed back fully bracketed, exactly as it was read — because the thing an expression tool gets quietly wrong is not rejecting bad input but grouping good input differently from the way you meant it, and a truth table gives you no way to notice. The row that catches people is implication: p → q is false only when p holds and q does not, so a false p makes the whole thing true whatever q says.
What this generator does
Reads the expression you type — in symbols, arrows or words, whichever notation you already use — and evaluates it on every assignment of its variables. Leave the box empty and it builds one instead, over two to five variables. Either way the table is printed with the first variable changing slowest, which is the conventional order.
How to use this tool
- Type your expression, using whatever notation you already write in — symbols, arrows or words all work.
- Check the bracketed version above the table: that is how it was read.
- Read the table, and the verdict: tautology, contradiction, or satisfiable but neither.
- Leave the box empty instead if you want an expression drawn for you to practise on.
Understanding the controls
- Your expression
- Single letters for variables, and any accepted spelling of the connectives. Leave it empty to have one drawn for you.
- How many variables
- Between 2 and 5, for an expression drawn for you. When you type your own, the variables in it decide. The table doubles with each one, so five is already thirty-two rows.
- Expression depth
- How many levels of nested connectives in an expression drawn for you. Ignored when you type your own.
- Seed
- Any word reproduces the same drawn expression, so the same exercise can be set twice. It has no effect on an expression you typed, which is already the same every time.
Common use cases
- Working out what an expression from a textbook, a proof or a piece of code actually does
- Checking whether two expressions you suspect are equivalent really are, by comparing their tables
- Settling an argument about precedence by seeing the brackets the parser put in
- Practice at filling truth tables, with an expression drawn for you and an answer to check
- Showing why implication behaves as it does on a false antecedent
How this generator works
Each row is produced by evaluating the expression tree on that assignment. The check re-evaluates every row independently, confirms no assignment is repeated or missing, and recounts the true rows to confirm the tautology and contradiction verdicts. An expression you type gets one further check, and it is the one that matters: the tree is printed back with every bracket in place and then read again, and the two have to be the same tree. A printed form carrying all its brackets has no precedence left in it to get wrong, so a parser that had grouped your expression differently from the way you wrote it could not survive that round trip.
Randomness and fairness
An expression you type involves no randomness at all: the table is a function of what you wrote. Randomness comes in only when the box is left empty and one is drawn for you, from the browser's cryptographically secure generator. A seed then reproduces the same expression exactly, which makes that mode deterministic and therefore explicitly not cryptographically secure — it is a reproducibility measure and nothing here should stand in for one.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Five variables is the ceiling, because the table doubles each time and thirty-two rows is already the limit of what fits on a page.
- Only propositional logic — quantifiers, predicates and modal operators are outside what this covers.
- Variables are single letters, and there are no constants: an expression that is simply true or false has no table worth printing.
- No simplification is offered here; that is the simplification challenge's job.
- Tables are not stored between visits; seed one you want again.
Privacy and your data
Expressions and tables are computed in your browser. Nothing about the expression or your seed is transmitted or kept.
Related generators
- Logic Simplification Challenge GeneratorDeliberately over-complicated expressions built by applying an identity backwards, with the law named and equivalence proved on every assignment.
- Binary Puzzle GeneratorFill a grid with 0s and 1s: equal numbers in every row and column, never three in a row, no two lines alike.
- Karnaugh Map Challenge GeneratorGrey-coded Karnaugh maps filled from a real expression, with the largest valid groups found and each one proved to cover only true cells.
- Logic Gate Circuit GeneratorRandom acyclic gate circuits with their equivalent expression and full input-output table, the two required to agree everywhere.