How to use the logic gate truth table tool
Single gate mode
- Pick a gate — AND, OR, NOT, NAND, NOR, XOR or XNOR — and choose 2, 3 or 4 inputs.
- Tap the inputs on the symbol (or the buttons below it) to flip them between 0 and 1. The wires turn orange when they carry a 1, and the output updates instantly.
- Read the Boolean expression, the same logic written for Arduino/C, the full truth table and a common IC that contains that gate.
Boolean expression mode
Type any expression, such as (A & B) | !C, AB + A'C or A NAND B. The tool shows how it read your expression (fully bracketed), a live input panel, the complete truth table and the minterm/maxterm lists. It uses a small parser written for this page — your text is never run as code.
The seven basic gates
| Gate | Expression | Output is 1 when… | Common IC |
|---|---|---|---|
| AND | Y = A · B | all inputs are 1 | 74HC08 |
| OR | Y = A + B | at least one input is 1 | 74HC32 |
| NOT | Y = ¬A | the input is 0 | 74HC04 |
| NAND | Y = ¬(A · B) | not all inputs are 1 | 74HC00 |
| NOR | Y = ¬(A + B) | all inputs are 0 | 74HC02 |
| XOR | Y = A ⊕ B | the inputs are different | 74HC86 |
| XNOR | Y = ¬(A ⊕ B) | the inputs are the same | 74HC7266 |
Formula
A truth table with n inputs has 2ⁿ rows. The rows count in binary, with A as the most significant bit:
Operator order in the expression mode follows C: NOT first, then AND, then XOR, then OR. So A | B & C means A | (B & C). When in doubt, add brackets.
Multi-input XOR and XNOR
A 3- or 4-input XOR here works the way chained 2-input XOR chips do: the output is 1 when an odd number of inputs are 1. That makes XOR a parity checker, used to detect single-bit errors in data. XNOR is the opposite — 1 for an even number of 1s. It is not "exactly one input is high".
Common mistakes
- Forgetting precedence.
A + B · CisA + (B · C), not(A + B) · C. The "Read as" line shows exactly how the expression was understood. - Using
&and&&as if they were the same in C. For 0/1 values they give the same truth table, but&works bit by bit on whole bytes, while&&treats any non-zero value as true. - Writing
~on an Arduinoint.~1is −2, not 0. Use!for single true/false values, or mask with& 1. - Reading the NAND symbol as AND. The small circle (bubble) on the output means "inverted".
- Mixing up letters. In this tool
ABmeans A AND B — variable names are single letters.
Show your logic on a display with the seven-segment display encoder, convert binary values with the programmer's base converter, or turn logic into motor speed with the PWM duty cycle calculator. Looking for a science-fair idea with gates? See our school science exhibition robotics project ideas, and learn hands-on in our workshops.





