Truth Table Calculator
Build the truth table for any logic expression. Supports AND, OR, NOT, XOR, NAND, NOR, implies and iff, and says if it is a tautology or contradiction.
Truth Table Calculator
Background.
A truth table calculator takes a sentence of propositional logic and works out its value under every possible combination of true and false for the variables inside it. Type (P AND Q) OR NOT R and it produces all eight rows in one pass, counts that five of them come out true, and reports the verdict: this expression is a contingency, meaning it is neither always true nor always false. That three-way classification — tautology, contradiction, contingency — is the whole point of building the table, and it is the reason truth tables have survived unchanged since Emil Post and Ludwig Wittgenstein both published the method in 1921.
The mechanical part is simple enough to do by hand and tedious enough to get wrong. With n variables there are 2^n rows, because each variable independently takes one of two values. Two variables give four rows, three give eight, five give thirty-two, and six give sixty-four, which is where this calculator stops. Every row is then evaluated by working outwards from the innermost parentheses, applying one connective at a time. The arithmetic is trivial; the errors come from precedence, from mis-ordered rows, and from the implication connective, which behaves in a way that reliably surprises people the first several times they meet it.
That implication rule deserves saying plainly because it causes more confusion than the rest of the subject combined. P IMPLIES Q is false in exactly one row — the one where P is true and Q is false. Every other row, including both rows where P is false, comes out true. So 'if the moon is made of cheese then 2 + 2 = 5' is a true statement of propositional logic. Material implication is not causation and carries no claim that P has anything to do with Q; it only promises that you will never find a true antecedent sitting above a false consequent. Once that lands, the classical laws stop looking arbitrary: P IMPLIES Q turns out to be exactly the same table as NOT P OR Q, and the contrapositive NOT Q IMPLIES NOT P matches it row for row.
Precedence is the other place a calculator has to commit to something, and honesty requires saying that textbooks do not fully agree. This page fixes the ordering NOT, then AND and NAND, then OR, NOR and XOR, then IMPLIES, then IFF, with NOT and IMPLIES grouping to the right and everything else to the left. The first four levels are near-universal; where XOR, NAND and NOR sit is genuinely author-dependent, and no appeal to authority settles it. Rather than leave you guessing, the calculator prints your expression back fully parenthesised under 'Read as', so you can see precisely which grouping it used before you trust the table. If the echo is not what you meant, add parentheses — they always win.
Two conventions govern how to read the output. Variable columns are listed alphabetically rather than in order of appearance, so R AND P is tabulated with P on the left. Rows run from all-true down to all-false, with the rightmost variable alternating fastest, which is the ordering used in most discrete mathematics texts. Each row is printed as a pattern of T and F followed by the result, so TTF→T means the expression is true when the first two variables are true and the third is false.
Equivalence checking is the most common practical use and needs no special mode. To test whether two expressions are logically equivalent, join them with IFF and run the result: if the whole thing comes back a tautology, they have identical truth tables and are interchangeable. That single trick handles De Morgan's laws, distribution, exportation, double negation, and every homework question of the form 'show that these two statements are equivalent'. The same idea tests an argument for validity: join the conjunction of the premises to the conclusion with IMPLIES, and a tautology means the argument is valid.
The calculator accepts word operators and symbols interchangeably, so AND, ∧, & and && are all the same connective, as are ->, → and =>, and <->, ↔ and IFF. Input is case-insensitive, meaning p and P are the same variable. Multi-letter names are rejected rather than guessed at: PQ is an error, not shorthand for P AND Q, because silently inventing a conjunction would produce a confidently wrong table.
What is truth table calculator?
A truth table is an exhaustive listing of the truth value of a compound proposition under every possible assignment of truth values to its atomic variables. It is a decision procedure: because propositional logic has only finitely many assignments for finitely many variables, checking all 2^n rows settles definitively whether a formula is valid, unsatisfiable, or neither. A formula true in every row is a tautology, also called a logical truth or a valid formula. A formula false in every row is a contradiction, or unsatisfiable. A formula true in some rows and false in others is a contingency, and its truth then depends on facts rather than on logic alone. Emil Post's 1921 paper and Wittgenstein's Tractatus, published the same year, independently introduced the tabular method that is still used today.
How to use this calculator.
- Type your expression using single letters for variables — P, Q, R, and so on. Case does not matter.
- Use any spelling of the connectives you like: AND or ∧ or & or &&; OR or ∨ or |; NOT or ¬ or ~ or !; IMPLIES or -> or →; IFF or <-> or ↔. NAND, NOR and XOR are also supported.
- Check the 'Read as' line before you trust the table. It shows your expression fully parenthesised, so you can confirm the calculator grouped it the way you meant. Add parentheses if it did not.
- Read the verdict: tautology means true in every row, contradiction means false in every row, contingency means it depends on the variables.
- Read the table itself against the column order shown. Rows run from all-true to all-false, with the rightmost variable alternating fastest.
- To test whether two expressions are logically equivalent, join them with IFF and check whether the result is a tautology.
- To test whether an argument is valid, write (premise1 AND premise2) IMPLIES conclusion and check whether that is a tautology.
The formula.
Building a truth table is three steps: enumerate the assignments, evaluate the formula once per assignment, then classify the column of results.
Enumeration is where the 2^n comes from. Each of the n variables is independently true or false, so the multiplication principle gives 2 × 2 × … × 2 assignments, and each one is a row. This calculator lists them in the standard textbook order: the first row assigns true to everything, the last assigns false to everything, and the rightmost variable alternates on every row while the leftmost changes only once. Reading a row index as a binary numeral with 0 meaning true reproduces exactly that order, which is how the rows are generated internally.
Evaluation applies the connective definitions, which are fixed and not open to interpretation. NOT flips a value. AND is true only when both operands are true. OR is inclusive, so it is true unless both operands are false. XOR is true exactly when the two operands differ. NAND and NOR are the negations of AND and OR. IFF is true exactly when the two operands agree. IMPLIES is false in exactly one case — a true antecedent with a false consequent — and true in all three others, which is the rule that makes 'if false then anything' come out true.
Parsing has to resolve precedence before any of that can happen, and precedence is the one place where authors differ. This page applies NOT first, then AND and NAND, then OR, NOR and XOR, then IMPLIES, then IFF. NOT and IMPLIES associate to the right, so P -> Q -> R is read as P -> (Q -> R), while AND, OR, XOR, NAND, NOR and IFF associate to the left. The first four precedence levels are close to universal in the literature; the placement of XOR, NAND and NOR is genuinely author-dependent, and the calculator handles the ambiguity by echoing the grouping it used rather than by pretending there is a single right answer. Parentheses override everything and are always honoured.
Classification compares two exact integers. If the count of true rows equals the total row count, the formula is a tautology. If the count of true rows is zero, it is a contradiction. Anything strictly between is a contingency. No rounding occurs anywhere on this page and no tolerance is involved, so a formula that is false in exactly one row out of sixty-four is a contingency, not a near-tautology — the boundary is a single row wide on both sides and is tested there.
A formula with no variables at all, such as TRUE AND FALSE, still has one row, because 2^0 = 1. Its verdict is whichever of tautology or contradiction matches its single value, which is the mathematically correct answer rather than an edge case to be special-pleaded.
A worked example.
Take the expression (P AND Q) OR NOT R. It uses three variables, so the table has 2^3 = 8 rows, and the columns are P, Q, R in alphabetical order. Work down the rows from all-true to all-false. With P, Q and R all true, P AND Q is true and NOT R is false, so the disjunction is true. With P and Q true and R false, P AND Q is still true and NOT R is now also true, so the result is true again. With P true, Q false and R true, P AND Q collapses to false and NOT R is false, so the whole thing is false — the first false row. With P true, Q false and R false, P AND Q is still false but NOT R is true, so the result is true. The bottom half is easier because P is false, which forces P AND Q to false in all four rows and leaves the answer entirely to NOT R. So the result is false when R is true and true when R is false: FTT is false, FTF is true, FFT is false, FFF is true. Collecting the column gives TTT→T, TTF→T, TFT→F, TFF→T, FTT→F, FTF→T, FFT→F, FFF→T. Five rows are true and three are false, so the verdict is a contingency: the expression is neither a logical law nor a logical impossibility, and whether it holds depends on the actual values of P, Q and R. The five satisfying assignments are TTT, TTF, TFF, FTF and FFF. Notice that every row with R false is satisfying, which the structure predicts — NOT R alone is enough to make the disjunction true — and that among the rows with R true, only the one where P and Q are both true survives. The 'Read as' line comes back as ((P ∧ Q) ∨ ¬R). That confirms the calculator applied NOT before OR, and used your parentheses around P AND Q rather than reassociating anything. Had you typed P AND Q OR NOT R with no parentheses at all, the precedence rules would have produced exactly the same grouping, because AND already binds tighter than OR.
Frequently asked questions.
How many rows does a truth table have?
What is the difference between a tautology, a contradiction and a contingency?
Why is 'P implies Q' true when P is false?
How do I check whether two expressions are logically equivalent?
How do I use a truth table to check whether an argument is valid?
What operator precedence does this calculator use?
In what order are the rows and columns listed?
Can I use TRUE and FALSE as constants?
Why does the calculator reject PQ instead of reading it as P AND Q?
References& sources.
- [1]Levin, Oscar. Discrete Mathematics: An Open Introduction, 3rd edition, §3.1 "Propositional Logic" — the implication table (T, F, T, T for the rows TT, TF, FT, FF), the definition of a tautology as "a statement which is true on the basis of its logical form alone", the biconditional test for logical equivalence, and the doubling row count (4 rows for two statements, 8 for three, 16 for four). Open access; retrieved 2026-07-29.
- [2]Stanford Encyclopedia of Philosophy, "Conditionals", §2.1 "Two Kinds of Truth Condition" — the material conditional: "'If A, B' is false when A is true and B is false. In all other cases, 'If A, B' is true", and its equivalence to ∼(A ∧ ∼B) and to ∼A or B. An independent, non-mathematical confirmation of the connective most often implemented backwards. Open access; retrieved 2026-07-29.
- [3]Weisstein, Eric W. "Truth Table." MathWorld — Wolfram Research. Defines a truth table as "a two-dimensional array with n+1 columns" whose "first n columns correspond to the possible values of n inputs, and the last column to the operation being performed", which is the layout this page reproduces in text. Retrieved 2026-07-29.
- [4]Post, Emil L. "Introduction to a General Theory of Elementary Propositions." American Journal of Mathematics 43, no. 3 (1921): 163–185 — the origin of the truth-table decision procedure and of the tautology/contradiction classification. Gated (JSTOR); cited bibliographically, not retrieved. No connective semantics on this page is taken from it.
- [5]Wittgenstein, Ludwig. Tractatus Logico-Philosophicus (1921), propositions 4.31 and 4.442 — the truth-table schema published independently of Post in the same year. Project Gutenberg carries the full C. K. Ogden translation; the catalogue record was verified, the full text was not machine-readable at fetch time, so this is a bibliographic citation.
- [6]Mendelson, Elliott. Introduction to Mathematical Logic, 6th edition. CRC Press, 2015, §1.2 "Truth Tables" — the standard connective semantics. Print reference, cited bibliographically; not retrieved during authoring. Every connective table this page implements is independently confirmed by the Levin and SEP entries above.
- [7]Enderton, Herbert B. A Mathematical Introduction to Logic, 2nd edition. Academic Press, 2001, §1.2 "Truth Assignments" — the formal definition of a truth assignment. Print reference, cited bibliographically; not retrieved during authoring.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 977 calculators remain free
- No billing is enabled