0/1 Boolean Logic Utility

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.

✓ Boolean Expressions ✓ AND / OR / NOT ✓ XOR / XNOR ✓ NAND / NOR ✓ Up to 5 Variables ✓ Automatic Rows
T/F
Boolean Truth Table
● Ready
Use variables A–Z and operators AND, OR, NOT, XOR, XNOR, NAND and NOR. Parentheses are supported.
Truth Table Options
Operator precedence: NOT is evaluated first, followed by AND/NAND, XOR/XNOR, then OR/NOR. Use parentheses whenever you want to make the intended grouping explicit.
Generated Truth Table Valid Expression
Variables
Rows
True Results
False Results
Expression Analysis

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 | 0

What 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
12
24
38
42⁴16
52⁵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 | 0

In 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 | 0

NOT 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 | 1

XOR 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 | 0

XNOR 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 | 1

XNOR 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 | 1

NAND 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 | 1

Truth 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 | 0

Using 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
1NOTUnary inversion
2AND, NANDConjunction family
3XOR, XNORExclusive comparison
4OR, NORDisjunction 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 B

This 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 B

How 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 rows

The 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.

Truth Table Generator FAQs

What is a truth table?
A truth table lists every possible combination of Boolean input values and shows the resulting output of a logical expression.
How many rows are in a two-variable truth table?
Two variables produce 2², or four, possible combinations.
How many rows are in a three-variable truth table?
Three variables produce 2³, or eight, rows.
How many rows are in a four-variable truth table?
Four variables produce 16 possible combinations.
What is the AND truth table?
AND is true only when both inputs are true.
What is the OR truth table?
OR is true whenever at least one input is true.
What is the XOR truth table?
For two inputs, XOR is true when the inputs differ and false when they are equal.
What is XNOR?
XNOR is the complement of XOR. It is true when corresponding Boolean inputs are equal.
What is NAND?
NAND means NOT AND. It is false only when both inputs are true.
What is NOR?
NOR means NOT OR. It is true only when both inputs are false.
Can I use parentheses?
Yes. Parentheses can be nested and are recommended for making complex Boolean expressions unambiguous.
What operator is evaluated first?
NOT has the highest priority, followed by AND/NAND, XOR/XNOR, then OR/NOR. Parentheses override the default precedence.
What is a tautology?
A tautology is an expression whose truth-table result is true for every possible input combination.
What is a contradiction?
A contradiction is an expression that is false for every possible input combination.
Can I copy the generated truth table?
Yes. The tool provides plain-text and CSV copy options after generating the table.
Scroll to Top