Uni-Sine
Computer ScienceData and logic

Truth table generator for any logic expression

A truth table lists every combination of true (1) and false (0) for the inputs of a logic expression, and the output for each. With n inputs there are 2ⁿ rows, so three inputs give 8. This truth table generator builds the full table for any expression you type, in words (AND, OR, NOT), logic symbols (∧ ∨ ¬) or electronics notation (· + ′), with a column for each step, and says whether the expression is a tautology, a contradiction or neither.

It opens on (A AND B) OR NOT C. Open the full truth table generator over this page to type your own.

Try it

Truth Table Generator

Build the truth table for any logic expression

Go to its page

How to use the truth table generator

  1. Type the expression in the Expression box. Variables are single letters, and you can mix notations: A AND B, A ∧ B, A·B and AB (implied AND) all mean the same.
  2. Choose how the answer is written: AND OR, ∧ ∨ ¬ or · + ′.
  3. Turn on Show each step to get a column for every part of the expression, not just the final output.
  4. Read the result: tautology, contradiction or contingent, the number of rows, and which rows are true and false.
  5. Below the table are the canonical forms: the expression rebuilt from its true rows (sum of minterms) and from its false rows (product of maxterms).
  6. Try the examples, or press Random problem in the Practice section.
OperationWordsSymbolsTrue when
NOTNOT A¬A or A′A is false
ANDA AND BA ∧ B or A·BBoth are true
ORA OR BA ∨ B or A + BAt least one is true
XORA XOR BA ⊕ BExactly one is true
NANDA NAND BA ↑ BNot both true
NORA NOR BA ↓ BNeither is true
ImpliesA IMPLIES BA → B or A -> BExcept when A is true and B false
If and only ifA IFF BA ↔ B or A <-> BBoth the same

It handles up to 8 variables, which is 256 rows. XNOR is also accepted, as the opposite of XOR.

How to make a truth table by hand

  1. Count the variables, n. The table has 2ⁿ rows.
  2. List every combination by counting in binary: 000, 001, 010 and so on.
  3. Add a column for each part of the expression, working from the inside out: brackets and NOT first, then AND, then OR.
  4. Fill in each column row by row, using the columns you already have.

Worked examples you can check in the generator

Example 1: (A AND B) OR NOT C

ABCA AND BNOT COutput
000011
001000
010011
011000
100011
101000
110111
111101

The output is true on 5 of the 8 rows: whenever C is false, and also when A and B are both true. Numbering the rows 0 to 7 as binary, it is true on rows 0, 2, 4, 6 and 7. It is contingent: true on some rows and false on others.

Example 2: XOR

A XOR B is true only when the inputs differ: on 01 and 10, false on 00 and 11. The same table comes from A′B + AB′ in electronics notation, one of the generator's examples, which shows the two expressions are equivalent.

Example 3: tautology and contradiction

A OR NOT A is true on every row, so it is a tautology. A AND NOT A is false on every row, a contradiction. The generator names these at the top of the result.

Example 4: checking De Morgan's law

De Morgan's law says NOT (A AND B) is the same as NOT A OR NOT B. Type (NOT (A AND B)) IFF (NOT A OR NOT B). If the two sides always match, IFF is true on every row, and the generator reports a tautology. That is how to prove any two expressions are equivalent with a truth table.

Example 5: implication

A → B is false only when A is true and B is false. It is true on the other three rows, including both rows where A is false. This surprises many people: a promise "if it rains, I'll take an umbrella" isn't broken on a dry day.

Try one

practice
Pick an answer, then check it.
On how many rows of its truth table is A OR B true?

Common mistakes

  • Missing rows. With n inputs there are exactly 2ⁿ rows. Count in binary so none are skipped.
  • Ignoring the order of operations. NOT binds tightest, then AND, then OR. Use brackets when in doubt.
  • Mixing up OR and XOR. OR is true when both inputs are true; XOR is not.
  • Applying NOT to the wrong part. NOT (A AND B) is not the same as NOT A AND NOT B.
  • Typing variable names longer than one letter. The generator reads AB as A AND B.

Common questions

How many rows does a truth table have?
2ⁿ for n inputs: 4 rows for two inputs, 8 for three and 16 for four.
How do you make a truth table?
List every combination of the inputs by counting in binary, add a column for each part of the expression from the inside out, and fill each row in.
What is a tautology?
An expression that is true on every row of its truth table, such as A OR NOT A.
How do you prove two logic expressions are equivalent?
Show their output columns match on every row. In the generator, join them with IFF and check for a tautology.
What notation can I type?
Words (AND, OR, NOT, XOR, NAND, NOR, XNOR, IMPLIES, IFF), symbols (∧ ∨ ¬ ⊕ → ↔), or electronics notation (· + ′, with AB meaning A AND B).

Revision cards

Read the front, say your answer, then flip to check.

Where to go next

  • Solve it

    Truth Table Generator

    Build the truth table for any logic expression

    Open the tool
  • Test it

    AP Computer Science Principles

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
  • Test it

    College Discrete Math

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
Read next
Computer Science · Data and logicLogic gate simulator: build circuits, see the truth tableBuild logic circuits from AND, OR, NOT, NAND, NOR and XOR gates, flip switches and watch the signals, with a live truth table and an expression per lamp.