Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

AND gate using NAND gates: two gates, live

An AND gate takes two NAND gates: the first computes NAND(A, B), and the second, with both inputs tied together, inverts it. NOT NAND(A, B) = A AND B, so Y is 1 only when A and B are both 1.

NAND means NOT AND, so AND is a NAND followed by an inverter, and a NAND gate with its inputs joined is an inverter: NAND(X, X) = NOT X. This is also how CMOS chips build AND: a 4-transistor NAND plus a 2-transistor inverter, because the NAND is the natural CMOS gate (see the CMOS AND gate). The mirror of this circuit is the OR gate from two NOR gates, and the OR gate from three NAND gates and the NAND universal gates page complete the set.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “AND gate from NAND gates”, https://digiwleea.wleeaf.dev/tools/build/and-from-nand/

What you need

Step by step

  1. Place inputs A and B and a probe Y.
  2. Feed A and B into the first NAND gate.
  3. Feed its output into both inputs of a second NAND gate and probe that as Y.
  4. Try all four rows: Y is 1 only when A and B are both 1.

AND from NAND truth table

ABN = NAND(A, B)Y = A AND B
0010
0110
1010
1101

All input rows are checked on the live circuit before the page is built.

You can also read the full theory in the lesson on the NAND gate. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.

More builds: Universal gates: NAND only, NOR only

All 246 build guides, by topic

Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.

Open the AND gate from NAND gates in the lab →

Frequently asked

How many NAND gates are needed to make an AND gate?

Two: one NAND gate, then a second NAND gate with its inputs tied together to invert the result. NOT NAND(A, B) = A AND B.

Why are AND gates built from NAND gates in CMOS?

Because a CMOS NAND needs only four transistors and an inverter two, while there is no direct CMOS AND. An AND gate is a NAND plus an inverter, six transistors.

How many NAND gates make an OR gate?

Three: two NANDs invert A and B, and a third NANDs the inverted inputs, NAND(NOT A, NOT B) = A OR B.