Free tool

Truth table generator. Every row, every step.

Type a logic formula in any common notation, from ¬ ∧ ∨ → to !, &&, || and ->, and get its complete truth table, with a column for each step if you want one. It tells you whether the formula is a tautology, checks it against a second formula for equivalence, and copies the table as CSV, Markdown or LaTeX.

Free, no sign-up. It runs in your browser.

Your formula

Letters and words are variables; T and F mean true and false. Type ->, &, |, ~ or use the buttons.

Standard notation:
(p → q) ∧ ¬q → ¬p
Grouped as:
((p → q) ∧ ¬q) → ¬p
Show values as
First row
Variable columns
A column for each part, in the order you'd work it out

Tautology: true in all 4 rows.

Tautology: true in all 4 rows.

Truth table for (p → q) ∧ ¬q → ¬p
pq(p → q) ∧ ¬q → ¬p
TTT
TFT
FTT
FFT

Check equivalence

Two formulas are equivalent when they have the same value in every row.

A second formula, in any notation. Both are checked over all their variables together.

Try ¬p ∨ ¬q against ¬(p ∧ q), or pick an example above.

Normal forms

Sum of minterms (DNF)

(¬p ∧ ¬q) ∨ (¬p ∧ q) ∨ (p ∧ ¬q) ∨ (p ∧ q)

Σm(0, 1, 2, 3)

Product of maxterms (CNF)

⊤

none

Terms are numbered in binary, with true as 1 and p as the leftmost digit.

How to use it

  1. Step 1: Type your formula

    Use the symbol buttons or plain keys: ~ for not, & for and, | for or, -> for implies and <-> for if and only if. Letters and words are variables.

  2. Step 2: Read the table

    The last column is the formula's value for every combination of true and false. Turn on steps to see each part worked out in order.

  3. Step 3: Check it or export it

    Type a second formula to test equivalence, then copy the table as CSV, Markdown or LaTeX for your homework or notes.

How to build a truth table by hand

A truth table lists every way the variables in a formula can be true or false, and the formula's value in each case. With n variables there are 2ⁿ combinations: p and q give 4 rows, three variables give 8, and ten give 1,024. That doubling is why tables get unwieldy fast, and why this generator stops at ten.

Start by writing the variables as the first columns and filling them in a fixed pattern, so you can't miss a row. In the textbook layout the first variable is true for the top half of the rows and false for the bottom half, the next one switches every quarter, and the last one alternates every row. Computer science courses often count up in binary instead, starting from all 0s. The First row setting switches between the two.

Then work from the inside out. Give each part of the formula its own column, smallest pieces first, and finish with the whole formula. Take (p → q) ∧ ¬q → ¬p, the rule called modus tollens. Its parts, in the order you'd work them out, are p → q, then ¬q, then (p → q) ∧ ¬q, then ¬p, and finally the whole implication.

Down the four rows (p and q both true, then T F, F T and F F), p → q comes out T, F, T, T and ¬q is F, T, F, T. Their conjunction is true only in the last row: F, F, F, T. ¬p is F, F, T, T. The final column asks whether the conjunction implies ¬p. In the first three rows the conjunction is false, so the implication holds; in the last row both sides are true. The result is T in all 4 rows, so the formula is a tautology, which is another way of saying modus tollens is a valid rule. Switch on Show steps above and you'll see exactly these columns.

The operators, and how each course writes them

Not (¬p) flips a value. And (p ∧ q) is true only when both sides are: T, F, F, F down the standard four rows. Or (p ∨ q) is inclusive, true when at least one side is: T, T, T, F. Exclusive or (p ⊕ q) is true when exactly one side is: F, T, T, F.

Implies (p → q) is false in just one row, where p is true and q is false: T, F, T, T. If and only if (p ↔ q) is true when the two sides match: T, F, F, T. Not-and (p ↑ q, the Sheffer stroke) and not-or (p ↓ q, the Peirce arrow) are the negations of and and or: F, T, T, T and F, F, F, T. Digital-logic courses lean on them because every other operator can be built from ↑ alone, or from ↓ alone.

Notation varies more than the logic does. Discrete-math and philosophy textbooks write ¬ ∧ ∨ → ↔, some older ones use ~ for not and ⊃ for implies, and some write ≡ for if and only if. Digital-logic courses write A·B for and, A + B for or and A' for not. Programming languages use !, && and || (not, and and or in Python), with ^ for exclusive or. LaTeX uses \lnot, \land, \lor, \to and \leftrightarrow. The generator reads all of these, so you can paste a formula from your notes as it is. The one exception is writing AB for A and B: type A·B instead, because AB is read as a single variable named AB.

When brackets are left out, the generator applies the order programming languages use for !, &, ^ and |: ¬ binds tightest, then ∧ and ↑, then ⊕, then ∨ and ↓, then →, and ↔ last. So ¬p ∧ q ∨ r → s is read as ((¬p ∧ q) ∨ r) → s. Implication groups to the right, so p → q → r means p → (q → r); the other operators group to the left. Not every textbook agrees, and some never let you mix ∧ and ∨ without brackets, so add brackets whenever there's any doubt. The Grouped as line under your formula shows exactly how it was read.

Tautologies, contradictions and equivalent formulas

Every formula falls into one of three groups. A tautology is true in every row, like p ∨ ¬p. A contradiction is false in every row, like p ∧ ¬p. Everything else is a contingency: its truth depends on the values you plug in. p → q is a contingency, true in 3 of its 4 rows. The line above the table tells you which group your formula is in and how many rows are true.

Two formulas are logically equivalent when they have the same value in every row, which is the same as saying that A ↔ B is a tautology. The classic examples are De Morgan's laws, ¬(p ∧ q) ≡ ¬p ∨ ¬q and ¬(p ∨ q) ≡ ¬p ∧ ¬q; the contrapositive, p → q ≡ ¬q → ¬p; material implication, p → q ≡ ¬p ∨ q; and distribution, p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r). Put one side in the formula box and the other in Compare with to check any of them.

When two formulas aren't equivalent, a single row proves it. Compare p → q with its converse, q → p, and the generator reports the first row where they differ: row 2, where p is true and q is false, so p → q is false but q → p is true. Writing out that one counterexample is usually all a question asking you to disprove an equivalence needs.

For formulas with up to five variables, you also get the canonical normal forms. The disjunctive normal form (DNF) joins one term with ∨ for each true row; the conjunctive normal form (CNF) joins one clause with ∧ for each false row. For p → q that gives (¬p ∧ ¬q) ∨ (¬p ∧ q) ∨ (p ∧ q), listed as Σm(0, 1, 3), and the single clause ¬p ∨ q, which is material implication again. To typeset the formula itself in a write-up, try the LaTeX equation editor.

Mistakes that cost marks

Treating a false condition as a false implication. p → q is true whenever p is false, whatever q is. "If it rains, the match is canceled" isn't broken on a dry day, whether or not the match goes ahead. It only fails when it rains and the match is played anyway. That is why p → q has three true rows.

Reading or as exclusive. In everyday speech, "tea or coffee" usually means one, not both. In logic, ∨ includes the case where both are true, so p ∨ q is true in 3 of 4 rows while p ⊕ q is true in only 2. If a question means exactly one, it needs ⊕, or the equivalent (p ∨ q) ∧ ¬(p ∧ q).

Mixing up the converse and the contrapositive. p → q is equivalent to ¬q → ¬p, but not to its converse q → p or its inverse ¬p → ¬q. Assuming a precedence your course doesn't use. Read as (p ∧ q) ∨ r, the formula p ∧ q ∨ r is true in 5 of 8 rows; read as p ∧ (q ∨ r), it's true in only 3. And dropping rows: a table for three variables needs all 8, in a pattern you can check, or a contingency can pass for a tautology.

If you want the theory in full, the free open textbook forall x: Calgary, listed below, builds truth tables from the ground up in its third part, including complete tables, partial tables and shortcuts for working them out faster.

Sources

  1. Magnus, P. D., Button, T., Trueman, R., & Zach, R. (2025). forall x: Calgary. A Free and Open Introduction to Formal Logic. Open Logic Project, Fall 2025 edition.

Stuck on a logic problem set?

Skolar, the AI tutor in Skolight, can work through discrete-math problems step by step using the lecture notes and slides you've added, and cites the parts of your material it used. You can attach a photo of a problem sheet, then ask it to quiz you on the same ideas to check they've stuck.

See the AI Tutor

Questions.

More free tools. No sign-up either.

  • Free tool

    LaTeX Table Generator

    Turn a spreadsheet or a typed grid into clean booktabs LaTeX, with captions, labels and escaping handled.

  • Free tool

    LaTeX Equation Editor

    A live LaTeX preview with a symbol palette, plain-English errors, and MathML, PNG and SVG export.

  • Free tool

    Standard Deviation Calculator

    Sample and population standard deviation, variance, quartiles and outliers, with the working shown.

Want this done for you? Start from your own notes.

Skolight turns your lectures and readings into flashcards, quizzes, mock exams and a study plan. The Free plan needs no card.

  • No card requiredGet started in seconds
  • Trusted by 100k+ studentsJoin a growing community
  • Works with any documentPDFs, notes, slides and more