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—
Boolean expression—
Gate type—
Universal gate?—

De Morgan's laws tie the family together: NOT (A AND B) = (NOT A) OR (NOT B), and NOT (A OR B) = (NOT A) AND (NOT B). That symmetry is exactly why NAND or NOR alone can build every other gate — flip inputs and output and one universal gate becomes another.

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.

Reading the simulation

What the lit wires, the output LED and the highlighted table row are telling you.

1

Bits flow in and light the wires

The two input toggles set A and B to 0 or 1, and those bits travel down the wires into the gate symbol. Each wire glows cyan for logic 1 and stays grey for 0, and a small 0/1 tag sits on every wire so you can read its value at a glance. For a NOT gate only the A wire is live — B is disabled, because an inverter has a single input.

2

The gate applies its rule; the LED shows the bit

The symbol carries the gate's one fixed rule, and the negated gates (NAND, NOR, XNOR, NOT) add the little bubble that flips the result. The output wire and the LED on the right show the answer: the LED lights and reads 1 when the gate outputs 1, and stays dark on 0. The readouts spell the same result as a boolean expression and name the gate type, and flag whether it is a universal gate.

3

The highlighted row enumerates every case

Beside the symbol is the gate's full truth table — four rows for a two-input gate (00, 01, 10, 11), two for NOT. The row matching your current inputs is boxed and highlighted, so as you toggle A and B the highlight walks down the table and you can see how each of the possible input combinations maps to an output.

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, each wire carries its 0/1 tag, 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, or use a preset, and the symbol and rule change together.

3

Universal gates and 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. NAND and NOR are universal: any other gate can be built from copies of just one of them, which is why real chips are seas of identical NAND gates. As you toggle A and B, the matching row is highlighted so you can check your 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.

Classroom activity

A ready-to-assign lab using the simulation above. Free to use — nothing to install or sign up for, and no student data leaves the browser.

High school, College10–20 minInteractive simulation

Learning objectives

  • Identify the basic logic gates and their symbols.
  • Build truth tables for each gate.
  • Combine gates to make a simple circuit.

Variables to change

  • Gate type (AND, OR, NOT, NAND, NOR, XOR)
  • Input values (0/1)

Procedure

  1. Select each gate and toggle its inputs through all combinations.
  2. Record the output for every input combination (its truth table).
  3. Wire two gates together and predict, then check, the output.

Observations

Fill in a truth table for each gate you test.

Questions

  1. When is an AND gate’s output 1?
  2. When is an OR gate’s output 1?
  3. What does a NOT gate do?
  4. How does XOR differ from OR?
  5. Why are NAND and NOR called universal gates?

Explanation

Logic gates output a 1 or 0 from their inputs by fixed rules: AND needs all inputs true, OR any, NOT inverts, XOR needs them different. Their truth tables fully define them, and NAND or NOR alone can build any digital circuit.

Answer key (for instructors)
  • 1. Only when all inputs are 1.
  • 2. When at least one input is 1.
  • 3. Inverts its input: 0 becomes 1 and 1 becomes 0.
  • 4. XOR outputs 1 only when the inputs differ; it is 0 when both are 1.
  • 5. Any logic function can be built entirely from NAND gates alone (or NOR gates alone).

Educators: link or embed this simulation freely in your LMS or course guide.

Add This Logic Gate Simulator to Your Website

Put the Logic Gate Simulator on your own page — free, no sign-up, no watermark. It runs entirely in your visitors' browsers. Copy the snippet and paste it into your page's HTML.

The credit line under the widget links back to LK Forge — please keep it so others can find it too.