Logic Gate Simulator

The building blocks of every computer, one gate at a time. Pick a gate — AND, OR, NOT, NAND, NOR, XOR or XNOR — flip the binary inputs, and watch the wires and output light up for logic 1. Beside the gate, its truth table highlights the row for whatever inputs you've set, so the rule becomes obvious. It's pure boolean logic — exact, and running entirely on your device.

You are in the Physics lab.

Cyan wire = logic 1, grey = 0. The highlighted truth-table row matches your inputs.
Input A
Input B
Output
Expression
Every computer is a mountain of these seven gates. Each takes one or two binary inputs (0 or 1) and follows one fixed rule: AND needs both 1s, OR needs at least one, NOT flips its input, and XOR fires only when the two differ. The negated versions — NAND, NOR, XNOR — just invert the result. Stack millions of them and you get memory, arithmetic and a processor. The truth table beside each gate is the whole rule, and nothing here is approximate: boolean logic is exact.

How It Works

Binary inputs, one fixed rule per gate, and the truth table that captures it.

1

Bits in, a bit out

A logic gate takes one or two inputs, each either 0 (low) or 1 (high), and produces a single output bit. In this simulator the input dots and wires glow cyan for 1 and stay grey for 0, and the output LED lights when the gate outputs 1 — so you can trace the signal straight through.

2

One rule per gate

AND outputs 1 only if both inputs are 1; OR if either is; NOT inverts a single input. NAND, NOR and XNOR are those with the output flipped (shown by the little bubble on the symbol), and XOR outputs 1 only when the inputs differ. Switch gates and the symbol and rule change together.

3

The truth table

List every input combination and the output for each and you have the truth table — the complete definition of the gate. A two-input gate has four rows; NOT has two. As you toggle A and B, the matching row is highlighted, so you can read off the rule and check your own predictions against it.

What are the seven basic logic gates?
AND, OR and NOT, plus the four built from them: NAND (NOT-AND), NOR (NOT-OR), XOR (exclusive-OR) and XNOR. AND outputs 1 only when both inputs are 1; OR when at least one is; NOT inverts a single input; NAND and NOR are their negations; XOR outputs 1 when the inputs differ, XNOR when they match. This simulator switches between all seven.
What is a truth table?
A truth table lists every combination of a gate's inputs and the output for each. A two-input gate has four rows (00, 01, 10, 11); a one-input gate like NOT has two. It fully defines the gate. As you toggle the inputs here, the matching row is highlighted.
What is the difference between XOR and OR?
A plain OR outputs 1 whenever at least one input is 1 — including when both are. An exclusive-OR (XOR) outputs 1 only when the inputs differ. So for 1 and 1, OR gives 1 but XOR gives 0. XOR is the "one or the other, but not both" gate — the heart of binary addition and parity.
Why are NAND and NOR called universal gates?
Because any other gate — AND, OR, NOT and everything built from them — can be made using only NAND gates, or only NOR gates. That is why a whole processor can be built from a sea of identical NAND gates. Toggle to NAND or NOR to see the negated output that makes it possible.

Teaching digital logic or Boolean algebra? You can embed this simulator on your own site free — one line of code, no sign-up.