Truth Table Generator
Last updated: 27 June 2026
Reviewed by Gavin Meiring, Lead research and primary author ยท Doctoral Candidate (Corporate Governance) ยท Research and drafting assisted by AI
- George Boole published 'An Investigation of the Laws of Thought' in 1854, founding the Boolean algebra that truth tables describe.
- Claude Shannon's 1937 master's thesis showed Boolean algebra could design telephone switching circuits โ the birth of digital logic design.
- Every computer calculation reduces to logic gates, and a single type of gate โ the NAND gate โ is enough to build any logic circuit at all.
Truth Table Generator
A truth table generator takes a logical expression involving Boolean variables and produces a complete table showing the output for every possible combination of true/false inputs. It is used by computer science students, logic learners, digital circuit designers, and programmers who need to verify the behaviour of logical statements.
How to Use the Truth Table Generator
- Enter your logical expression using variables (A, B, C...) and operators (AND, OR, NOT, XOR, IMPLIES, NAND, NOR).
- You can use standard symbols: & or AND, | or OR, ! or NOT, ^ or XOR, -> or IMPLIES, <-> or IFF.
- Click Generate to produce the full truth table.
- Review each row, which shows one combination of inputs and the resulting output.
- Use the simplification tool to find the equivalent simplified expression in conjunctive or disjunctive normal form.
The Formula
The operators and their rules:
NOT A: output is true when A is false, false when A is true. A AND B: output is true only when both A and B are true. A OR B: output is true when at least one of A or B is true. A XOR B: output is true when exactly one of A or B is true (exclusive or). A IMPLIES B (A -> B): output is false only when A is true and B is false. A IFF B (A <-> B): output is true when A and B have the same value.
For n variables, the truth table has 2^n rows.
Real-World Example
Expression: (A AND B) OR (NOT A AND C)
Variables: A, B, C. Rows: 2^3 = 8.
A=F, B=F, C=F: (F AND F) OR (T AND F) = F OR F = F A=F, B=F, C=T: (F AND F) OR (T AND T) = F OR T = T A=F, B=T, C=F: (F AND T) OR (T AND F) = F OR F = F A=F, B=T, C=T: (F AND T) OR (T AND T) = F OR T = T A=T, B=F, C=F: (T AND F) OR (F AND F) = F OR F = F A=T, B=F, C=T: (T AND F) OR (F AND T) = F OR F = F A=T, B=T, C=F: (T AND T) OR (F AND F) = T OR F = T A=T, B=T, C=T: (T AND T) OR (F AND T) = T OR F = T
Result: true in rows 2, 4, 7, and 8.
Logic in Computing and Electronics
Boolean logic is the foundation of all digital electronics and computer programming. Every transistor in a CPU operates as an AND, OR, or NOT gate, and complex operations from addition to memory storage are built by combining millions of these simple gates. Digital circuit designers use truth tables to verify that a circuit behaves correctly before fabrication, and they use them to simplify circuits using techniques such as Karnaugh maps. In programming, conditional statements (if/else, while, switch) evaluate Boolean expressions. Understanding how compound conditions like (A AND B) OR NOT C evaluate helps programmers write correct and efficient code. In mathematics, truth tables are used to prove logical equivalences and tautologies (expressions that are always true, such as A OR NOT A) and contradictions (always false, such as A AND NOT A).
Frequently Asked Questions
What is the difference between OR and XOR? OR (inclusive or) is true when at least one input is true, including the case where both are true. XOR (exclusive or) is true only when exactly one input is true. When A=true and B=true, OR gives true but XOR gives false. XOR is commonly used in programming for toggling bits and in encryption algorithms.
What does IMPLIES mean in logic? A IMPLIES B (written A -> B) is false only in the case where A is true and B is false. In all other cases it is true. This matches the intuitive meaning of a conditional promise: "If it rains (A), I will carry an umbrella (B)." The promise is only broken if it rains and you did not carry an umbrella. If it does not rain, the promise is vacuously kept regardless of whether you carried an umbrella.
How many rows does a truth table have? A truth table with n variables has 2^n rows because each variable can independently be either true or false. One variable gives 2 rows, two variables give 4 rows, three give 8 rows, and ten variables give 1,024 rows. For expressions with many variables, truth tables become unwieldy, which is why algebraic simplification methods are preferred for large circuits.
What is a tautology? A tautology is a logical expression that is true for every possible assignment of truth values to its variables. The classic example is A OR NOT A, which is always true. Tautologies are important in formal logic and proof theory. The opposite, a contradiction, is always false (for example A AND NOT A). Expressions that are neither always true nor always false are called contingencies.
Reading the row count before you start
The table size is fixed by the number of variables, not by the expression. Every variable doubles the row count, because each existing row splits into one row with the new variable true and one with it false.
| Variables | Rows | Variables | Rows |
|---|---|---|---|
| 1 | 2 | 6 | 64 |
| 2 | 4 | 7 | 128 |
| 3 | 8 | 8 | 256 |
| 4 | 16 | 9 | 512 |
| 5 | 32 | 10 | 1,024 |
The generator above accepts up to five variables, so a single generated table never runs past 32 rows. Past that point the honest description of a function is an algebraic form rather than a table, which is why circuit designers drop the table and simplify instead.
A worked table: two expressions that agree on every row
De Morgan's laws are the standard check that a generated table is doing what you think it is. The claim is that NOT (A AND B) gives the same output as (NOT A) OR (NOT B) on all four rows.
| A | B | NOT (A AND B) | (NOT A) OR (NOT B) |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
Both columns hold the value 1 on three of the four rows and 0 on the row where A and B are both true. The two expressions are equivalent, and this is exactly what a truth table is for: four lines of work replace an argument. Generate both expressions and compare the result columns, and the table settles the question.
A worked table: a three-variable expression
The same approach scales to three variables. Two expressions over A, B and C produce eight rows, and the columns below come from the generator's own evaluation order.
| A | B | C | A XOR B XOR C | (A AND B) OR C |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
The parity column holds 1 on four of the eight rows, which is what an odd number of true inputs gives for any number of variables. The second column holds 1 on five rows. Neither expression is a tautology or a contradiction, so both are contingencies: true for some assignments and false for others.
What the generator accepts
The operator set is the one below. Anything outside it is not understood.
| Operator | Word form | Symbol form | Result is 1 when |
|---|---|---|---|
| NOT | NOT A | ! A | A is false |
| AND | A AND B | A && B | both inputs are true |
| NAND | A NAND B | not available | at least one input is false |
| OR | A OR B | A with two vertical bars | at least one input is true |
| NOR | A NOR B | not available | both inputs are false |
| XOR | A XOR B | A ^ B | exactly one input is true |
| XNOR | A XNOR B | not available | both inputs have the same value |
Precedence runs NOT first, then AND and NAND, then OR, XOR, NOR and XNOR together at one level, read left to right. So NOT A AND B is read as (NOT A) AND B, and A AND B OR C is read as (A AND B) OR C. Brackets override the order and are the safest way to write anything with more than two operators.
Two operators that appear in textbooks are not in the list. There is no IMPLIES and no IFF symbol. To test an implication, write it in the form the generator understands: A implies B is the same as (NOT A) OR B.
| A | B | A implies B | (NOT A) OR B |
|---|---|---|---|
| 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
Two ways the input can catch you out
The first is the symbol forms. The generator reads && for AND and || for OR, with two characters each. A single ampersand or a single vertical bar is not an operator, and the parser skips it. Type A & B and the generator still finds two variables and still prints four rows, but the result column mirrors A, because the operator between them was discarded. The table looks complete and answers a different question from the one asked. Use the word forms when you are unsure.
The second is multi-letter words. Variables are single letters, so a word such as IMPLIES is read as seven separate variables, I, M, P, L, I, E and S, and the run stops at the five-variable limit with a message rather than a table. The same applies to TRUE and FALSE. Write A and B, not the words.
What a truth table cannot do
The method is exhaustive and that is both its strength and its limit. It settles an equivalence for every assignment, which a spot check does not. It also grows exponentially, and it says nothing about the simplest form of the expression it describes. Finding that form needs a separate method: factoring common terms by hand, or a Karnaugh map when the variable count is small enough to draw. The generator returns the table and the count of rows that evaluate to 1, and the simplification is the next step rather than part of the output.
Boolean algebra as a system of calculation comes from George Boole's An Investigation of the Laws of Thought (1854). The link from that algebra to switching circuits, and so to the logic gates a truth table describes, is the subject of Claude Shannon's 1937 master's thesis, "A Symbolic Analysis of Relay and Switching Circuits", published in 1938.
Also try these free tools: