PublicSoftTools
Tools16 min read·PublicSoftTools Team·May 2026

Truth Table Generator — Generate Truth Tables for Logic Expressions

A truth table lists all possible combinations of truth values for the variables in a logical expression, together with the resulting output for each combination. Truth tables are essential tools in logic, digital electronics, computer science, and mathematics. The free truth table generator on PublicSoftTools produces complete truth tables for any Boolean expression with up to eight variables.

Logic Gates and Operators

GateSymbolBehaviourExpression
AND∧ or &Output TRUE only when ALL inputs are TRUEA AND B = A ∧ B
OR∨ or |Output TRUE when AT LEAST ONE input is TRUEA OR B = A ∨ B
NOT¬ or ~Output is the opposite (negation) of the inputNOT A = ¬A
XOR⊕ or ^Output TRUE when inputs DIFFER (exclusive or)A XOR B = A ⊕ B
NANDNOT AND: output FALSE only when ALL inputs TRUEA NAND B = ¬(A ∧ B)
NORNOT OR: output TRUE only when ALL inputs FALSEA NOR B = ¬(A ∨ B)
XNOREquivalence: output TRUE when inputs are THE SAMEA XNOR B = ¬(A ⊕ B)

How to Use the Truth Table Generator

  1. Open the truth table generator.
  2. Enter a Boolean expression using variables A, B, C, etc. Use standard notation:
    • AND or && for logical AND
    • OR or || for logical OR
    • NOT or ! for logical NOT
    • XOR or ^ for exclusive OR
  3. Click Generate. The tool creates a complete truth table with all 2ⁿ rows (where n is the number of variables).
  4. The table shows intermediate column values for sub-expressions, making it easy to follow the evaluation step by step.

Truth Table for All Two-Input Gates

ABANDORXORNANDNORXNOR
0 (FALSE)0 (FALSE)000111
0 (FALSE)1 (TRUE)011100
1 (TRUE)0 (FALSE)011100
1 (TRUE)1 (TRUE)110001

Applications of Truth Tables

ApplicationHow truth tables are used
Digital circuit designTruth tables verify that a logic circuit produces the intended output for all possible inputs before building the physical circuit
Karnaugh maps (K-maps)A truth table is the starting point for K-map simplification — minimising the number of logic gates needed to implement a function
Programming conditionalsUnderstanding AND/OR/NOT helps write correct boolean expressions in if statements and while loops
Computer science proofsPropositional logic proofs use truth tables to verify that an argument is valid — that the conclusion is always true when premises are true
SQL query logicSQL WHERE clauses combine conditions with AND, OR, NOT — truth tables clarify which rows will be selected under complex conditions
Electrical engineeringLogic gates are the building blocks of all digital electronics: CPUs, memory, communication chips

Building Complex Expressions Step by Step

For the expression (A AND B) OR (NOT C):

  1. Evaluate the innermost sub-expressions first, following operator precedence: NOT before AND before OR.
  2. Add an intermediate column for NOT C — the negation of C.
  3. Add an intermediate column for A AND B.
  4. The final column combines these: (A AND B) OR (NOT C).

For three variables (A, B, C), the truth table has 2³ = 8 rows. The generator automatically handles the enumeration of all possible combinations and evaluates each sub-expression.

Boolean Algebra Laws

Boolean algebra has laws similar to ordinary algebra, with some important differences. Truth tables can be used to verify these laws:

Identity laws

Complement laws

De Morgan's Laws

De Morgan's laws are essential for simplifying logic expressions:

These allow you to convert NAND to NOT-OR and NOR to NOT-AND, which is important in circuit design where one gate type may be cheaper or more available than another. Verify these laws using the truth table generator: enter both sides of each law and confirm the output columns are identical.

Distributive laws

Note that Boolean algebra's second distributive law (OR over AND) has no equivalent in ordinary arithmetic — this often surprises students from a mathematics background.

Logical Equivalence and Tautologies

Two expressions are logically equivalent if their truth tables produce identical output columns for all input combinations. For example, A AND B is equivalent to NOT (NOT A OR NOT B) — this can be verified by generating truth tables for both and comparing.

A tautology is an expression that is always TRUE, regardless of input values. Example: A OR NOT A is always TRUE. A contradiction is always FALSE. Example: A AND NOT A is always FALSE.

In formal logic, tautologies represent logically necessary truths — statements that are true in all possible worlds. Proving that an argument's conclusion is a tautological consequence of its premises validates the argument.

NAND and NOR: Universal Gates

NAND and NOR are called universal gates because any Boolean function can be implemented using only NAND gates (or only NOR gates). This is important in chip design because:

Any logic circuit from a simple adder to a full CPU can theoretically be built using only NAND gates. Modern CPUs contain billions of transistors realising billions of logic operations built from this principle.

Truth Tables in Programming

Boolean expressions in code (Python, JavaScript, Java, C) follow the same truth table rules. Some important programming-specific considerations:

Short-circuit evaluation

Most languages evaluate AND and OR expressions left to right and stop as soon as the result is determined: for A and B, if A is False, B is never evaluated (cannot change the result). For A or B, if A is True, B is never evaluated. This is called short-circuit evaluation and can mask errors if B has side effects.

Truthy and falsy values

In dynamic languages like Python and JavaScript, values that are not strictly True or False are coerced to boolean context: 0, empty string, null, None, and undefined are typically falsy; non-zero numbers, non-empty strings, and non-null objects are truthy. Truth tables apply to the coerced boolean values, not the original values.

Common Questions

How many rows does a truth table with n variables have?

A truth table for n variables has 2ⁿ rows: 2 variables → 4 rows, 3 variables → 8 rows, 4 variables → 16 rows, 8 variables → 256 rows. This exponential growth is why truth tables become impractical for large numbers of variables — computer science uses other proof methods for complex logical systems.

What is the difference between XOR and OR?

OR (inclusive or) is TRUE when at least one input is TRUE — including when both are TRUE. XOR (exclusive or) is TRUE only when exactly one input is TRUE — it is FALSE when both inputs are TRUE. In natural language, "would you like tea or coffee?" usually implies XOR (one or the other, not both); in logic and programming, OR is inclusive unless stated otherwise.

Can I use the truth table generator for propositional logic proofs?

Yes. Propositional logic uses the same operators (∧ for AND, ∨ for OR, ¬ for NOT, → for implication, ↔ for biconditional). The generator handles AND, OR, NOT, XOR, and their complements. For implication (A → B), enter it as NOT A OR B (since A → B is logically equivalent to ¬A ∨ B) and verify by comparing truth tables.

What is the biconditional operator?

The biconditional (A ↔ B, read "A if and only if B") is TRUE when A and B have the same truth value — the same as XNOR. It represents logical equivalence: "A is true if and only if B is true." Enter it as XNOR (or as NOT XOR) in the truth table generator.

Generate Your Truth Table

Enter any Boolean expression — AND, OR, NOT, XOR, NAND, NOR — to generate a complete truth table with intermediate steps.

Open Truth Table Generator