Truth Table Generator
Generate complete truth tables from Boolean logic expressions using AND, OR, NOT, XOR, XNOR, NAND and NOR. Enter an expression with up to five variables and automatically calculate every possible combination of true and false inputs.
—
Truth Table Generator
The Truth Table Generator creates a complete Boolean truth table from a logic expression. Enter variables such as A, B and C together with operators including AND, OR, NOT, XOR, XNOR, NAND and NOR, and the tool evaluates the expression for every possible input combination.
Truth tables are fundamental to Boolean algebra, digital logic, programming, propositional logic and electronic circuit design. They show exactly how a logical expression behaves for every possible combination of its input variables.
This generator supports up to five variables, which means it can produce tables from two rows for a single variable through thirty-two rows for five variables.
How to Generate a Truth Table
Enter a Boolean expression such as A AND B, NOT A, A XOR B or (A OR B) AND C. The generator automatically detects the variables used in the expression.
Press Generate Truth Table. Every possible true and false assignment is calculated and displayed along with the final expression result.
Expression:
A AND B
A | B | Result
--------------
1 | 1 | 1
1 | 0 | 0
0 | 1 | 0
0 | 0 | 0What Is a Truth Table?
A truth table is a structured list showing the output of a logical expression for every possible combination of its inputs. Each variable can have two states: true or false.
For n Boolean variables, the complete truth table contains 2ⁿ rows. Therefore two variables produce four combinations, three variables produce eight and four variables produce sixteen.
| Variables | Possible Combinations | Truth Table Rows |
|---|---|---|
| 1 | 2¹ | 2 |
| 2 | 2² | 4 |
| 3 | 2³ | 8 |
| 4 | 2⁴ | 16 |
| 5 | 2⁵ | 32 |
AND Truth Table
AND returns true only when both input conditions are true.
A | B | A AND B
-----------------
1 | 1 | 1
1 | 0 | 0
0 | 1 | 0
0 | 0 | 0In digital electronics, this behavior corresponds to the basic AND logic gate.
OR Truth Table
OR returns true when at least one input is true. It returns false only when every input condition is false.
A | B | A OR B
---------------
1 | 1 | 1
1 | 0 | 1
0 | 1 | 1
0 | 0 | 0NOT Truth Table
NOT is a unary operator, meaning it operates on one value. It simply reverses the Boolean state.
A | NOT A
---------
1 | 0
0 | 1XOR Truth Table
Exclusive OR, or XOR, returns true when the input bits differ. For two variables, exactly one input must be true.
A | B | A XOR B
-----------------
1 | 1 | 0
1 | 0 | 1
0 | 1 | 1
0 | 0 | 0XNOR Truth Table
XNOR is the inverse of XOR. It returns true when both Boolean values are equal.
A | B | A XNOR B
------------------
1 | 1 | 1
1 | 0 | 0
0 | 1 | 0
0 | 0 | 1XNOR is therefore often described as logical equivalence.
NAND Truth Table
NAND means NOT AND. It returns false only when both inputs are true.
A | B | A NAND B
------------------
1 | 1 | 0
1 | 0 | 1
0 | 1 | 1
0 | 0 | 1NAND is especially important in digital electronics because NAND gates can be combined to implement any Boolean function.
NOR Truth Table
NOR means NOT OR. It produces true only when both input values are false.
A | B | A NOR B
-----------------
1 | 1 | 0
1 | 0 | 0
0 | 1 | 0
0 | 0 | 1Truth Table for Three Variables
Three Boolean variables create eight possible input combinations because 2³ equals 8.
Expression:
(A OR B) AND C
A B C | Result
--------------
1 1 1 | 1
1 1 0 | 0
1 0 1 | 1
1 0 0 | 0
0 1 1 | 1
0 1 0 | 0
0 0 1 | 0
0 0 0 | 0Using Parentheses in Boolean Expressions
Parentheses control which part of an expression is evaluated first and can remove ambiguity from complex logic.
Expression 1:
A OR B AND C
Using normal precedence:
A OR (B AND C)
Expression 2:
(A OR B) AND C
These expressions can produce different results.For complicated expressions, explicit parentheses are recommended even when standard operator precedence would produce the intended result.
Boolean Operator Precedence
The generator applies a defined operator precedence when an expression does not contain enough parentheses.
| Priority | Operators | Description |
|---|---|---|
| 1 | NOT | Unary inversion |
| 2 | AND, NAND | Conjunction family |
| 3 | XOR, XNOR | Exclusive comparison |
| 4 | OR, NOR | Disjunction family |
Truth Tables in Boolean Algebra
Boolean algebra works with variables that have only two possible values. Depending on context, these may be written as true and false, T and F, 1 and 0, high and low, or on and off.
A truth table provides a direct way to verify whether two Boolean expressions behave identically. If every corresponding result row is the same, the expressions are logically equivalent.
Truth Tables for Logic Gates
Digital logic gates implement Boolean operations using electrical signals. A truth table defines the expected output state of each gate for every possible input combination.
Gate Boolean Operation
AND A AND B
OR A OR B
NOT NOT A
XOR A XOR B
XNOR A XNOR B
NAND A NAND B
NOR A NOR BThis makes truth tables useful when studying combinational logic circuits and validating gate-level designs.
Truth Tables in Programming
Programming conditions often contain several Boolean expressions joined using AND, OR or NOT. A truth table can reveal exactly when a complex condition evaluates to true.
Condition:
(A OR B) AND NOT C
Possible interpretation:
A = user has permission A
B = user has permission B
C = account is blocked
Result is true when:
(A or B is true) and C is false.Tautology, Contradiction and Contingency
Truth tables can classify logical expressions based on their final output column.
| Classification | Meaning |
|---|---|
| Tautology | Every result row is true |
| Contradiction | Every result row is false |
| Contingency | Some rows are true and some are false |
Tautology:
A OR NOT A
Contradiction:
A AND NOT A
Contingency:
A AND BHow Many Rows Does a Truth Table Need?
The number of rows is determined by 2 raised to the number of distinct Boolean variables.
1 variable:
2¹ = 2 rows
2 variables:
2² = 4 rows
3 variables:
2³ = 8 rows
4 variables:
2⁴ = 16 rows
5 variables:
2⁵ = 32 rowsThe generator automatically determines this count after extracting the variables from your expression.
Truth Table Generator Examples
Here are several expressions you can test directly with the generator.
A AND B
A OR B
NOT A
A XOR B
A XNOR B
A NAND B
A NOR B
(A OR B) AND C
NOT (A AND B)
(A XOR B) OR C
(A AND B) OR (C AND D)Common Truth Table Mistakes
One common mistake is forgetting one or more possible input combinations. For three variables, all eight combinations must be included for a complete table.
Another mistake is evaluating operators in the wrong order. NOT normally has higher priority than binary operators, while parentheses should be used whenever grouping needs to be explicit.
XOR and OR are also frequently confused. OR is true when one or both inputs are true, while XOR is false when both inputs are true.
Truth Table Generator Limitations and Notes
This generator supports up to five distinct single-letter variables from A through Z. Limiting the variable count keeps the generated table compact and practical for browser use.
Operator names should be written as AND, OR, NOT, XOR, XNOR, NAND or NOR. Operator names are case-insensitive, so expressions such as a and b are accepted and normalized internally.
The parser evaluates expressions locally in the browser and does not use JavaScript eval, making expression handling deterministic and restricted to the supported Boolean grammar.