The CNOT gate

The two-qubit gate that creates entanglement. A quantum if-statement.

Sohum Thakkar
Sohum Thakkar · CEO, Qolour
May 7, 2026

The CNOT (controlled-NOT) gate is the single most important gate in quantum computing.

The CNOT is the quantum equivalent of an if-statement. It says:

First, what does it mean to flip a qubit?

There are many ways to flip a qubit. Here are three of them. Each starts at |0⟩ (north pole) and ends at |1⟩ (south pole), but takes a different path:

Three ways to flip a qubit
X gate
180° about x
Y gate
180° about y
Some other gate
180° about (x + y)

All three flip a |0⟩ to a |1⟩, and vice versa. We have to choose one!

The flip in the CNOT is specifically the X gate, a 180° rotation about the x-axis.

So really, CNOT says:

Let's see what that looks like.

What does a controlled flip look like?

When the first qubit is |1⟩

The first qubit is |1⟩ (down), so CNOT applies an X gate to the second.

control · |1⟩
target · |0⟩
CNOT0%

The second qubit flipped from |0⟩ to |1⟩, just like applying X. The state becomes |11⟩. The first is unchanged. It's the boss; CNOT only ever touches the second.

When the first qubit is |0⟩

Now what if the first qubit is |0⟩ instead? What do you think happens?

Predict, then check it for yourself:

control · |0⟩
target · |0⟩
CNOT0%

Nothing changes. The first qubit was |0⟩, so the if-statement didn't trigger. The state stays at |00⟩.

In superposition

Here's the interesting case. What if we set the first to something in between |0⟩ and |1⟩, a 50-50 superposition? (We get there by applying a Hadamard first.) That means we're starting from the state:

1√2(|0⟩ + |1⟩) |0⟩

Now we have two possibilities (or worlds) for the first qubit. In the visualization below, we color them red and blue. Notice that in the beginning, in both the red and blue worlds, the second qubit is in the "up" position. The worlds overlap on that qubit, so we just get white.

However, as we do the CNOT, the red world and the blue world split apart. In the red world the first qubit is in the 0 position; in the blue world it's in the 1 position, so only the blue world flips.

control · |+⟩
Entanglement0%
target · |0⟩
CNOT0%
The first qubit starts in superposition. Watch what happens to both spheres.

So picture the two worlds running in parallel:

  • Red world: the first qubit was |0⟩ all along. CNOT does nothing. We end at |00⟩.
  • Blue world: the first qubit was |1⟩ all along. CNOT flips the second qubit. We end at |11⟩.

Quantum mechanics doesn't pick one. It keeps both, weighted by the original 50-50 split. The result is (|00⟩ + |11⟩)/√2, a Bell state: a very famous entangled state.

What happens if you measure now?

The two qubits are now correlated. If we measure the first qubit, and find that it's down, we know that we are in the blue world. Therefore, the other qubit must be down too!

first qubit
Entanglement100%
second qubit
Press "Measure Z" and watch both worlds collapse together.

When we measure a quantum system, it causes a collapse, which means it erases all the other worlds.

Entanglement is a dependence between measurement outcomes. Clearly, the outcomes are dependent on each other, so they are definitely entangled before we measure! After we measure, though, there is no longer any dependence.

Another visualization

As an aside, the earlier visualization showed the two worlds that result from a Z-basis measurement (which is why the worlds were placed on the z-axis).

But you don't have to measure on the Z axis. You can measure in any direction. There are many more possible worlds we can end up in, all around the sphere.

This next visualization gives a unique color to every potential future state, for measurement in any direction. Again, correlated worlds on the two qubits are colored the same.

Note that this visualization is something you have to sit with for a while to fully grasp. We have a guide on entanglement that will help.

control · |+⟩
Entanglement0%
target · |0⟩
CNOT0%

Truth table

On the four classical inputs:

InputControlTarget beforeTarget afterOutput
|00⟩000|00⟩
|01⟩011|01⟩
|10⟩101 (flipped)|11⟩
|11⟩110 (flipped)|10⟩

The first qubit is never changed. The second is flipped exactly when the first equals 1. CNOT is its own inverse: apply it twice and you're back to the original state.

The matrix

In the computational basis (ordering |00⟩, |01⟩, |10⟩, |11⟩), CNOT is:

CNOT =1000010000010010

The top-left 2×2 block is the identity (first qubit = 0 leaves the second alone), and the bottom-right 2×2 block is the Pauli-X gate (first qubit = 1 flips the second).

How CNOTs are performed in the real world

CNOTs are performed in all sorts of ways on real qubits.

In electron-spin qubits (like trapped ions), two different lasers are shot at the two electrons we want to entangle. If the first electron is facing up, it absorbs its laser, which creates a micro-vibration in the whole trap. The second laser translates that vibration into a flip for the second qubit. This creates entanglement between the electron spins.

Illustration of two lasers entangling electron spins in an ion trap
Two lasers in an ion trap entangling the electron spins.

Why CNOT matters

Single-qubit gates by themselves can't entangle two qubits. You can rotate each qubit independently all day and they'll stay independent. To do anything genuinely multi-qubit, you need at least one two-qubit gate, and CNOT is the standard one.

Together with two specific single-qubit gates (Hadamard and the T gate), CNOT forms a universal gate set. Every quantum operation, on any number of qubits, can be built from those three to any precision you want. Most quantum hardware vendors implement exactly this gate set as their native operations.

Frequently asked questions

What does the CNOT gate do?

CNOT is a two-qubit gate. It flips the second qubit only when the first is in the |1⟩ state. If the first qubit is |0⟩, the second is left alone.

Why does CNOT create entanglement?

Apply a Hadamard to the first qubit to put it into superposition, then run CNOT. Now the two qubits are correlated. Measuring one immediately tells you the outcome of the other. Starting from |00⟩, this exact sequence (H then CNOT) gives you a Bell state, the simplest entangled pair.

What is the CNOT truth table?

On the four classical inputs:

InputOutput
|00⟩|00⟩
|01⟩|01⟩
|10⟩|11⟩
|11⟩|10⟩
Is CNOT reversible?

Yes. Like every quantum gate, CNOT is unitary and therefore reversible. In fact, it's its own inverse: applying CNOT twice returns you to where you started.

Why is CNOT so important?

Single-qubit gates can't generate entanglement. To do anything genuinely quantum across multiple qubits, you need at least one two-qubit gate, and CNOT is the standard choice. Together with H and T, CNOT forms a universal gate set, meaning any quantum operation can be built from those three.

What's the CNOT matrix?

A 4×4 matrix in the computational basis. In block form, it's the 2×2 identity on the (first qubit = 0) subspace and Pauli-X on the (first qubit = 1) subspace: exactly "flip the second qubit only if the first is 1."

Get Qubi

Hold entangled qubits.

We've built a pair of qubits you can hold in your hands. They help drive home the concepts, and they even connect to real quantum computers!