Truth table generator
A truth table lists a logic function's output for every possible combination of its inputs. Type a boolean expression and get its complete truth table, one row for every combination of inputs. It understands the words AND, OR, NOT, and XOR, plus NAND and NOR, and the usual symbols (&, |, +, !, ~, ^, a middle dot, and a trailing prime for NOT). It runs entirely in your browser, with no sign-up.
How to use it
Type an expression into the box (or click one of the example chips) and the table
updates as you type. Use single letters A to
H for the inputs. The tool finds which variables you used,
sorts them, and enumerates every combination: two variables give four rows, three
give eight, four give sixteen, and so on, up to eight variables.
You can write operators as words or as symbols, and mix them freely. These all mean
the same AND: A AND B, A & B,
A * B, and A · B. NOT can be a
word (NOT A), a prefix symbol (!A or
~A), or a trailing prime (A', and
(A + B)' for the whole group). When you are unsure how an
expression will be grouped, add parentheses: they always win.
Worked example: A XOR B
Exclusive OR (XOR) is 1 when its two inputs differ and 0 when they are the same. With two inputs A and B there are four rows. The first variable, A, is the most significant bit, so the rows count up in binary from 00 to 11:
| A | B | A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
The middle two rows (A and B different) are 1, and the outer two rows (A and B equal)
are 0. That is exactly what an XOR gate does, and it is the heart of a half adder: the
sum bit of A plus B is A XOR B, while the carry is
A AND B.
Accepted syntax and operator precedence
Operators, with every spelling the tool accepts:
- NOT:
NOT A,!A,~A, or a trailing primeA' - AND:
AND,&,*, or a middle dot· - OR:
OR,|, or+ - XOR:
XORor^; XNOR as the wordXNOR - NAND and NOR as words, read as NOT(A AND B) and NOT(A OR B)
- Grouping: parentheses
( ) - Variables: single letters
AtoH(lowercase is treated the same)
Precedence runs from highest (binds tightest) to lowest like this. Binary operators are left-associative. When in doubt, parenthesize.
NOT > AND > XOR / XNOR > OR > NOR > NAND
So A OR B AND C reads as A OR (B AND C),
because AND binds tighter than OR. Writing two operands side by side, like
AB or A B, is read as an implicit AND
(A AND B). It is convenient, but for anything non-trivial an
explicit operator is clearer, so prefer A AND B and reach for
parentheses whenever the grouping is not obvious.
Frequently asked
What syntax does the truth table generator accept?
Use the words AND, OR, NOT, XOR, NAND, NOR, or the symbols and (&), or (| or +), not (! or ~ or a trailing prime), xor (^), and a middle dot or star for and. Group with parentheses. Variables are single letters A to H.
How many rows does a truth table have?
Two to the power of the number of input variables. Two variables give four rows, three give eight, four give sixteen, and so on, one row for every combination of inputs.
What is the truth table for A XOR B?
Exclusive OR is 1 when the inputs differ. A=0 B=0 gives 0, A=0 B=1 gives 1, A=1 B=0 gives 1, and A=1 B=1 gives 0.
Want to build these gates for real instead of just tabulating them? Open the lab and wire up an XOR from transistors, or read the theory on truth tables and boolean algebra.
Related tools: Karnaugh map solver and boolean simplifier.
Open the lab →