Generate a truth table from a boolean logic expression.
Calculated locally in your browser.
How do you generate a truth table from a boolean expression?
For n variables there are 2ⁿ rows, one for each combination of inputs. Operator precedence is NOT, then AND, then XOR, then OR, with parentheses overriding it; 1 means true and 0 means false. A truth table lists every input combination and the resulting output, the definitive way to check whether two expressions are equivalent. A AND B is true only when both are 1.
Understanding your result
A truth table lists every possible combination of input values and the resulting output of the expression. It is the definitive way to check whether two logic expressions are equivalent.
Formula and method
For n variables there are 2ⁿ rows. Operator precedence is NOT, then AND, then XOR, then OR; parentheses override it. 1 means true and 0 means false.
Assumptions and limitations
The generator handles boolean expressions built from AND, OR, NOT and XOR with single-letter variables and parentheses. It does not support multi-character variable names, implication or equivalence operators, or numeric and arithmetic terms. Because each extra variable doubles the rows, very large expressions produce huge tables, so keep the variable count modest for readable output.
Worked example
A AND B is true only in the single row where both A and B are 1.
How to use this tool
- Enter a boolean expression.
- Use single-letter variables and logic operators.
- Read the truth table for all combinations.
Common mistakes to avoid
- Using multi-letter variable names — use single letters.
- Forgetting an operator between two variables (write A AND B, not A B).
About the Truth Table Generator
The Truth Table Generator builds the complete truth table for a boolean expression. Enter a formula using AND, OR, NOT and XOR with single-letter variables, and see the result for every combination of inputs.
Who should use this tool
Computer-science and electronics students, and developers working with boolean logic.
Benefits
- Every input combination evaluated.
- Words or symbols for operators.
- Supports up to six variables.
- Counts how often the expression is true.
Practical use cases
- Checking a logic-gate design.
- Simplifying a boolean expression.
- Studying for a discrete-maths exam.
Explore all Developer Tools tools
Frequently asked questions
Which operators are supported?
NOT, AND, OR and XOR — as words or the symbols !, &, | and ^. Parentheses group sub-expressions.
How many variables can I use?
Up to six, which produces a 64-row table. More than that becomes unwieldy to read.
Can I use implication or NAND in my expression?
The generator understands AND, OR, NOT and XOR with single-letter variables and parentheses. Operators like implication, equivalence, NAND and NOR are not built in, but you can express them using the supported set; for example, implication A to B can be written as NOT A OR B to get the same table.