Logic gate symbols and truth tables
There are seven basic logic gates: NOT, AND, OR, NAND, NOR, XOR and XNOR. Each has a standard symbol, a Boolean expression and a truth table. Here they are side by side, with a live page for each one.
All two-input gates in one 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 |
NOT has a single input: it outputs 1 for A = 0 and 0 for A = 1. Notice the pairs: NAND is AND inverted, NOR is OR inverted, and XNOR is XOR inverted, which is exactly what the small circle (the bubble) on their symbols means.
How to read the symbols
The flat-backed D shape is AND and the curved shield is OR. A bubble on the output inverts it, turning AND into NAND and OR into NOR. A second curved line behind the shield marks an exclusive OR (XOR), and the triangle with a bubble is the NOT gate (inverter). These are the distinctive-shape symbols of ANSI/IEEE Std 91; the IEC 60617 standard draws every gate as a rectangle with a sign inside instead: & for AND, ≥1 for OR, =1 for XOR and 1 for a buffer, with a small circle or flag for inversion.
Build them yourself
Every gate here is built from transistors: NOT from two, NAND and NOR from four, AND and OR from six. See them switch in the CMOS inverter, CMOS NAND and CMOS NOR builds, play with each gate in the interactive gate tour, or open the logic gate simulator. For any expression, the truth table generator writes the table for you.
Gates are the first step to a working computer. Build every one from CMOS transistors and work up to an 8-bit CPU in the free digiwleea lab, with the free theory course alongside.
Open the gate simulator →Frequently asked
What are the 7 basic logic gates?
NOT, AND, OR, NAND, NOR, XOR and XNOR. NOT has one input; the others usually have two, and AND, OR, NAND, NOR, XOR and XNOR also come with more inputs.
Which logic gates are universal?
NAND and NOR. Each one alone can build every other gate, and so any digital circuit, including a whole CPU.
What does the bubble on a gate symbol mean?
Inversion. A small circle on the output turns AND into NAND, OR into NOR and XOR into XNOR, and the triangle with a bubble is the NOT gate.
What is the difference between the ANSI and IEC gate symbols?
ANSI/IEEE Std 91 uses distinctive shapes (D shape, shield, triangle). IEC 60617 draws every gate as a rectangle with a sign inside: & for AND, ≥1 for OR, =1 for XOR and 1 for a buffer, with a small circle or flag marking inversion.