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.
Expression
Operators: AND (&&), OR (||), NOT (!), XOR (^), NAND, NOR, XNOR. Use parentheses for grouping.
Presets
How to Use
- 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
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
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
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
| A | B | AND | OR | NAND | NOR | XOR | XNOR |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 1 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 |
Boolean Operator Syntax Reference
| Operator | Word Form | Symbol | Example | Meaning |
|---|---|---|---|---|
| AND | AND | && or & | A AND B | Both inputs must be true |
| OR | OR | || or | | A OR B | At least one input true |
| NOT | NOT | ! | NOT A | Invert the input |
| XOR | XOR | ^ | A XOR B | Inputs must differ |
| NAND | NAND | — | A NAND B | NOT AND — false only when both true |
| NOR | NOR | — | A NOR B | NOT OR — true only when both false |
| XNOR | XNOR | — | A XNOR B | Inputs must be equal |