Truth Table Generator

A truth table shows all possible input combinations and the corresponding output for a boolean expression. With n variables: 2^n rows (2 vars = 4 rows, 3 = 8, 4 = 16, 5 = 32). AND truth table: 0,0→0; 0,1→0; 1,0→0; 1,1→1. OR: 0,0→0; 0,1→1; 1,0→1; 1,1→1. XOR: 0,0→0; 0,1→1; 1,0→1; 1,1→0. NAND is NOT AND; NOR is NOT OR. A tautology is always true; a contradiction is always false.

Generate truth tables for any boolean logic expression. Supports AND, OR, NOT, XOR, NAND, NOR, XNOR operators and up to 5 variables (32 rows). Detects tautologies and contradictions. Copy results as tab-separated data.

Works OfflineDark ModeNo Ads

Expression

Operators: AND (&&), OR (||), NOT (!), XOR (^), NAND, NOR, XNOR. Use parentheses for grouping.

Presets

How to Use

  1. 1

    Enter a boolean expression

    Type your logic expression using variables A-Z and operators: AND, OR, NOT, XOR, NAND, NOR, XNOR. Example: A AND B OR NOT C. Use parentheses for grouping.

  2. 2

    View the truth table

    The truth table generates instantly with all 2^n combinations. True rows are highlighted green. The result column shows 0 (false) or 1 (true) for each row.

  3. 3

    Check for special cases

    If all rows are 1, the expression is a tautology (always true). If all rows are 0, it is a contradiction (always false). The row counts show how many times the expression is true.

  4. 4

    Copy the table

    Click Copy to get the truth table as tab-separated values. Paste directly into Excel or Google Sheets for further analysis.

Frequently Asked Questions

What is a truth table?
A truth table is a mathematical table that shows the output of a boolean logic expression for every possible combination of input values. Each variable can be either true (1) or false (0). With n variables, there are 2^n rows: 2 variables = 4 rows, 3 variables = 8 rows, 4 variables = 16 rows. Truth tables are used in digital logic design, computer science, and propositional logic to verify expressions and design circuits.
What are the basic logic gates and their truth tables?
AND: output is 1 only when BOTH inputs are 1. OR: output is 1 when AT LEAST ONE input is 1. NOT: inverts the input (0 becomes 1, 1 becomes 0). XOR (exclusive OR): output is 1 when inputs DIFFER. NAND: NOT AND — output is 0 only when both inputs are 1. NOR: NOT OR — output is 1 only when both inputs are 0. XNOR: NOT XOR — output is 1 when inputs are EQUAL.
What is De Morgan's Law in boolean algebra?
De Morgan's Laws are two fundamental theorems in boolean algebra: (1) NOT(A AND B) = (NOT A) OR (NOT B), and (2) NOT(A OR B) = (NOT A) AND (NOT B). These laws are used to simplify logic circuits and convert NAND/NOR gates to equivalent AND/OR/NOT combinations. In digital logic: NAND gates alone can implement any boolean function, as can NOR gates alone — both are functionally complete.
What is a tautology vs a contradiction in logic?
A tautology is a boolean expression that is always true (1) regardless of input values. Example: A OR (NOT A) is always true. A contradiction (unsatisfiable formula) is always false (0) regardless of input values. Example: A AND (NOT A) is always false. This truth table generator automatically detects tautologies (all result rows = 1) and contradictions (all result rows = 0).
How do I write a boolean expression for the truth table generator?
Use single letters (A, B, C, ...) for variables. Supported operators: AND (write AND or &&), OR (write OR or ||), NOT (write NOT or !), XOR (write XOR or ^), NAND (write NAND), NOR (write NOR), XNOR (write XNOR). Use parentheses for grouping: (A AND B) OR C. Examples: 'NOT A OR B' is a conditional, '(A XOR B) AND C' is a 3-variable expression. Variables are case-insensitive.
What is the Majority function in boolean logic?
The Majority function with 3 inputs returns 1 when at least 2 of 3 inputs are 1: (A AND B) OR (B AND C) OR (A AND C). It is used in fault-tolerant systems and voting circuits. With 3 inputs, it is true for 4 out of 8 combinations (when 2 or more are true). This is different from the OR function (true when 1 or more are true) and the AND function (true only when all 3 are true).

Basic Logic Gates Truth Table

ABANDORNANDNORXORXNOR
00001101
01011010
10011010
11110001

Boolean Operator Syntax Reference

OperatorWord FormSymbolExampleMeaning
ANDAND&& or &A AND BBoth inputs must be true
OROR|| or |A OR BAt least one input true
NOTNOT!NOT AInvert the input
XORXOR^A XOR BInputs must differ
NANDNANDA NAND BNOT AND — false only when both true
NORNORA NOR BNOT OR — true only when both false
XNORXNORA XNOR BInputs must be equal

Related Tools