On this page 22 sections
Every digital device you own comes down to seven simple circuits. Your phone, your laptop, the chip inside your washing machine. Zoom in far enough and you’ll find the same seven decision-makers, copied and wired together by the billion.
That’s the good news about logic gates. The whole topic is seven symbols, seven truth tables and seven short expressions. You can get through all of it in one sitting, and this page is laid out so you can.
One warning before we start. I’m going to tell you not to memorize the tables. Stick around and I’ll show you why.
What are logic gates, really?
A logic gate is a tiny electronic circuit that takes one or more inputs and produces exactly one output. Every input and every output is either a 0 or a 1. Nothing in between.
In a real circuit, those 0s and 1s are just voltages. A 0 is a low voltage, close to 0 volts. A 1 is a high voltage, often 5 V or 3.3 V depending on the chip. The gate looks at its inputs, applies one fixed rule and sets its output.
Each gate can be described in three ways, and you’ll get all three for every gate below:
- A symbol. The shape you draw in a circuit diagram.
- A truth table. Every possible input combination, with the output for each one.
- A Boolean expression. The same rule written as a short line of algebra.
Three descriptions, one rule. Know any one of them and you can work out the other two.
The algebra comes from George Boole, a mathematician who worked out the rules of true-and-false math in the mid-1800s, long before electronics existed. It sat in math books for decades. Then in 1937, Claude Shannon showed in his master’s thesis at MIT that switching circuits obey the same rules. (Not bad for a student project.)
All 7 gates at a glance
Short on time? This table puts all seven logic gate symbols, expressions and rules in one place.
| Gate | Symbol | Boolean expression | Output is 1 when | 74-series chip |
|---|---|---|---|---|
| AND | ![]() | Y = A · B | all inputs are 1 | 7408 |
| OR | ![]() | Y = A + B | at least one input is 1 | 7432 |
| NOT | ![]() | Y = A′ | the input is 0 | 7404 |
| NAND | ![]() | Y = (A · B)′ | at least one input is 0 | 7400 |
| NOR | ![]() | Y = (A + B)′ | all inputs are 0 | 7402 |
| XOR | ![]() | Y = A ⊕ B | the two inputs are different | 7486 |
| XNOR | ![]() | Y = (A ⊕ B)′ | the two inputs are the same | 74266 |
A quick note on notation. I’m writing NOT with a prime mark, so A′ means “NOT A.” Your textbook might draw a bar over the letter instead. Same meaning.
The last column is the classic 74-series chip for each gate, in case you want to try them on a breadboard.
One more thing about the logic gate symbols on this page. They’re the American (ANSI/IEEE) shapes, the ones most textbooks use. There’s also a rectangular IEC style where every gate is a plain box with a label inside: & for AND, ≥1 for OR, =1 for XOR. If your diagram is all boxes, that’s why.
The three basic gates: AND, OR and NOT
These three are called the basic gates because every other gate on this page is some combination of them. Get these right and the remaining four are easy.
AND gate
The AND gate is the strict one. Its output is 1 only when every input is 1.
Think of two switches wired one after the other, with a bulb at the end. Close just one and nothing happens. The bulb lights only when both are closed.

The symbol looks like a capital D: flat on the input side, round on the output side. The Boolean expression is Y = A · B, read as “A AND B.” You’ll often see the dot dropped, so AB means the same thing.
AND gate truth table
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
OR gate
The OR gate is the easygoing one. Its output is 1 when at least one input is 1.
Same bulb, but now the two switches sit side by side. Either one can light it. Both can too.

The symbol has a curved back and a pointed front, a bit like an arrowhead. The expression is Y = A + B. Careful with that plus sign. It means OR, not addition (more on that trap below).
OR gate truth table
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
NOT gate
The NOT gate has a single input, and it flips it. A 0 goes in, a 1 comes out. A 1 goes in, a 0 comes out. That’s why it’s also called an inverter.

Its symbol is a triangle with a small circle on the tip. Remember that circle. It’s called a bubble, it always means “invert,” and it’s about to show up on three more gates. The expression is Y = A′.
NOT gate truth table
| A | Y |
|---|---|
| 0 | 1 |
| 1 | 0 |
The universal gates: NAND and NOR
Take an AND or an OR, stick a bubble on the output and you get these two. They look like minor variations. They’re not.
NAND gate
NAND is short for NOT AND. Its output is 0 only when every input is 1, and 1 the rest of the time. Put simply, it’s an AND gate with the answer flipped.

The symbol is the AND shape with a bubble on the output. The expression is Y = (A · B)′.
NAND gate truth table
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NOR gate
NOR is NOT OR. Its output is 1 only when every input is 0. Any 1 on the inputs pulls the output down to 0.

Draw it as the OR shape plus a bubble. The expression is Y = (A + B)′.
NOR gate truth table
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
Why they’re called universal gates
Here’s the thing that makes these two special. You can build every other gate on this page using nothing but NAND gates. Or nothing but NOR gates. That’s why they’re called universal gates.
A quick taste: tie both inputs of a NAND together and it behaves like a NOT. Put that after another NAND and you’ve got an AND.
Sounds like a party trick, right? It isn’t. The Apollo Guidance Computer, the machine that steered astronauts to the Moon, got all of its logic from a single gate type: the three-input NOR. The later version packed in roughly 5,600 of them.
And here’s my contrarian take. Most courses teach AND, OR and NOT first and treat NAND as an afterthought. I think that’s backwards if you care about how chips are really made.
In CMOS, the technology inside nearly every modern chip, a two-input NAND takes four transistors. An AND takes six, because it’s a NAND with an inverter bolted on. The “basic” gate is the expensive one.
I’m giving NAND and NOR their own deep dive soon, including how to build each of the other gates from them.
The exclusive gates: XOR and XNOR
The last pair asks a different question. Not “how many inputs are 1?” but “do the inputs agree?”
XOR gate
XOR stands for exclusive OR. With two inputs, the output is 1 when the inputs are different and 0 when they’re the same.
You’ve probably used one today. A staircase light with a switch at the top and another at the bottom works this way. Flip either switch and the light changes.

The symbol is the OR shape with an extra curved line across the input side. The expression is Y = A ⊕ B, and if you expand it you get A′B + AB′.
XOR gate truth table
| A | B | Y |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
XNOR gate
XNOR is XOR with the output flipped, so its output is 1 when the inputs are the same. That’s why some books call it the equality gate. Need to check whether two bits match? This is your gate.

The symbol is XOR plus a bubble. No surprise there. The expression is Y = (A ⊕ B)′, which expands to AB + A′B′.
XNOR gate truth table
| A | B | Y |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
There’s a lot more to this pair (parity checks, comparators, adders), so XOR and XNOR get their own article next.
What most people get wrong about these gates
Three mistakes show up again and again. All three are easy to avoid once you’ve seen them.
- Reading + as addition. In Boolean algebra, + means OR, so 1 + 1 = 1. Not 2.
- Putting the NAND bubble in the wrong place. NAND inverts the output, not the inputs. (A · B)′ and A′ · B′ are different things. Try A = 1 and B = 0: the first gives 1, the second gives 0.
- Thinking XOR means “exactly one input is 1.” That’s only true with two inputs. With three or more, XOR gives 1 when an odd number of inputs are 1, so 1, 1, 1 gives 1.
So why seven gates and not twelve?
Fair warning: this part gets a little nerdy.
A two-input gate has four rows in its truth table, and each row’s output can be 0 or 1. That makes 2 × 2 × 2 × 2 = 16 possible tables. No more exist.
Most of those 16 are useless. One always outputs 0. One always outputs 1. A couple just copy one input and ignore the other.
Six are useful enough to earn a standard symbol: AND, OR, NAND, NOR, XOR and XNOR. Add NOT, which only needs one input, and you land on seven.
How I’d learn all seven (skip the memorizing)
Don’t @ me, but I think memorizing truth tables row by row is a waste of an evening. Learn one sentence per gate instead:
- AND: 1 only if all inputs are 1.
- OR: 0 only if all inputs are 0.
- NOT: the opposite of the input.
- NAND: 0 only if all inputs are 1.
- NOR: 1 only if all inputs are 0.
- XOR: 1 if the two inputs differ.
- XNOR: 1 if the two inputs match.
From any of those lines you can rebuild the full table in about ten seconds. And you’ll still be able to do it a year from now, which is more than I can say for a memorized grid of 0s and 1s.
The logic gate symbols shrink the same way. There are only three shapes: the D, the arrowhead and the triangle. A bubble means “invert” and an extra curve means “exclusive.” Five ideas, not seven drawings.
Then go and play with them. Flip the inputs yourself in the logic gate simulator on this site and watch each output change. It beats rereading.
Where you’ll actually meet these gates
Start with addition. To add two bits, send them into an XOR and an AND at the same time. The XOR gives you the sum and the AND gives you the carry. Feed in 1 and 1: the sum is 0, the carry is 1, and “10” is binary for 2.
That little circuit is called a half adder. Two gates. Stack more of them on the same idea and you get the part of a processor that does arithmetic.
If you write code, you’ve already used gates without drawing a single symbol. The &, |, ^ and ~ operators in C, Java, JavaScript and Python are AND, OR, XOR and NOT, applied to every bit of a number at once. I’ve been writing software for more than 15 years, and these seven rules sit underneath every line of it.
And yes, you can still buy them one chip at a time. The 7400, four NAND gates in a single package, has been on sale since the 1960s. Yeah, that’s a thing.
Frequently asked questions
What are the 7 logic gates?
AND, OR, NOT, NAND, NOR, XOR and XNOR. The first three are the basic gates, NAND and NOR are the universal gates, and XOR and XNOR are the exclusive gates.
Which gates are universal?
NAND and NOR. Any digital circuit can be built from either one alone.
What’s the difference between OR and XOR?
One row. When both inputs are 1, OR gives 1 and XOR gives 0. Every other row is identical.
Your ten-minute homework
Here’s my takeaway. Logic gates aren’t a memory test. They’re seven small rules, and a rule you understand beats a table you memorized every single time.
So don’t just close this tab. Grab a sheet of paper and draw all seven symbols from memory. Write the one-line rule under each, then build each truth table from its rule. Whatever you can’t recall, scroll up and check.
Ten minutes. That’s the gap between having read about gates and knowing them. Next up I’m taking XOR and XNOR apart properly, and NAND and NOR after that. If today’s seven made sense, those will be fun.
Questions & comments
Did this work for you, or did you hit a different error? Ask below and we will help.