Logic Gate Truth Table Generator

See the symbol, truth table and Boolean expression of AND, OR, NOT, NAND, NOR, XOR and XNOR gates, or build a truth table from any expression.

  • Free, no signup
  • Works on mobile
  • Formula + worked example

How to use the logic gate truth table tool

Single gate mode

  1. Pick a gate — AND, OR, NOT, NAND, NOR, XOR or XNOR — and choose 2, 3 or 4 inputs.
  2. 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.
  3. 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

GateExpressionOutput is 1 when…Common IC
ANDY = A · Ball inputs are 174HC08
ORY = A + Bat least one input is 174HC32
NOTY = ¬Athe input is 074HC04
NANDY = ¬(A · B)not all inputs are 174HC00
NORY = ¬(A + B)all inputs are 074HC02
XORY = A ⊕ Bthe inputs are different74HC86
XNORY = ¬(A ⊕ B)the inputs are the same74HC7266

Formula

A truth table with n inputs has 2ⁿ rows. The rows count in binary, with A as the most significant bit:

rows = 2^n (2 inputs → 4, 3 → 8, 4 → 16) row number = A·2^(n−1) + B·2^(n−2) + … + last input·1 Σm(…) = rows where Y = 1 ΠM(…) = rows where Y = 0

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 · C is A + (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 Arduino int. ~1 is −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 AB means 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.

Frequently asked questions

What is a truth table?+

A truth table lists every possible combination of inputs to a logic circuit and the output for each one. A circuit with n inputs has 2ⁿ rows — 4 rows for 2 inputs, 8 for 3 and 16 for 4.

What is the difference between XOR and OR?+

OR gives 1 when at least one input is 1, including when both are 1. XOR (exclusive OR) gives 1 only when the inputs are different, so 1 XOR 1 is 0.

Why are NAND and NOR called universal gates?+

Because any other logic gate — and so any digital circuit — can be built from only NAND gates, or only NOR gates. For example, a NAND with both inputs joined acts as a NOT gate.

What does a 3-input XOR gate do?+

It gives 1 when an odd number of inputs are 1, the same as chaining two 2-input XOR gates. So 1, 1, 1 gives 1, and 1, 1, 0 gives 0. It is a parity checker, not an "exactly one" detector.

In what order are Boolean operators evaluated?+

NOT is evaluated first, then AND, then XOR, then OR — the same as in C and Arduino code. So A | B & C means A | (B & C). Use brackets whenever you want a different order.

From the Thinking Robot store

Shop all
All tools
WhatsApp