In short

A quantum circuit diagram is the notation every quantum-computing paper, textbook, and compiler uses to describe an algorithm. Each qubit is a horizontal wire; time flows left to right; gates are boxes sitting on one wire (single-qubit) or spanning several (multi-qubit); CNOT is a filled dot connected to an open circle with a plus on another wire; measurement is a meter-shaped box with a double line exiting to carry the classical outcome. Gates drawn at the same horizontal position (on different wires) happen in parallel. The circuit is read left to right as time, but the matrix product is read right to left — because the rightmost gate in the circuit is applied first in the matrix sense: U_\text{total} = U_k U_{k-1} \cdots U_2 U_1. By the end of this chapter you will be able to pick up any quantum paper, look at its main circuit, and trace the state at each step.

Open any quantum-computing paper on arXiv. Scroll past the abstract. Somewhere on page two or three, you will see a diagram that looks like a few horizontal lines with boxes and dots on them. This is a quantum circuit diagram — the universal notation for quantum algorithms — and it is the single most important reading skill in the field.

Once you can read circuits fluently, a whole door opens. The abstract of a paper tells you what the authors claim; the circuit tells you how. "We present a 7-qubit Bell-measurement circuit requiring only 2 CNOTs and three Hadamards" is a claim; the circuit diagram is the proof, readable in thirty seconds if you know the notation. Every real advance in quantum algorithms eventually appears as a circuit diagram, because the circuit is where the actual computation lives.

The good news: the notation is small. There are maybe ten symbols you need to know, each with a simple job. The bad news: different papers and different textbooks use slightly different conventions — qubit ordering, gate label spellings, measurement arrow styles — and recognising those conventions matters when you are reading a stranger's paper.

This chapter gives you the whole toolkit. By the end, you should be able to read any quantum circuit you are likely to encounter and — more importantly — write your own circuits to explain your algorithms to other people.

The basic rules — wires, boxes, and time

The five rules that cover 90% of every circuit you will see:

  1. One horizontal wire per qubit. A circuit with n wires describes a system of n qubits.
  2. Time flows from left to right. The input state sits at the left edge; the output at the right.
  3. Gates are boxes or vertical connections. A single-qubit gate is a square box on one wire. A multi-qubit gate spans multiple wires, usually via a vertical line connecting a "control" marker on one wire to a "target" marker on another.
  4. Two gates at the same horizontal position on different wires happen in parallel. They act simultaneously on their respective qubits.
  5. Measurement boxes sit at the end of a wire. A double line exiting the measurement box carries the classical bit (not a qubit line) to wherever it goes next.

That is the whole grammar.

Legend: every circuit symbol and what it meansA legend table with two columns. Left column shows a visual example of each circuit element. Right column describes it. Elements shown: a quantum wire with ket zero label; a single-qubit gate H box; a Pauli X box; a parametric rotation R_z of theta box; a CNOT with filled dot and open plus connected by vertical line; a Toffoli with two filled dots and one open plus; a controlled-U with filled dot and U box on target; a SWAP with two X marks connected; a measurement meter; a double line carrying classical bit; an ancilla labelled ket zero with a trashcan meaning discarded.|0⟩Quantum wirehorizontal line = one qubit, labelled with its input stateHSingle-qubit gatea box on one wire, labelled with the gate symbol (H, X, Y, Z, S, T, ...)Rz(θ)Parametric rotationa box with gate symbol and parameter — Rx(θ), Ry(θ), Rz(θ), U(α,β,γ)CNOTfilled dot (control) + open circle with plus (target), connected by vertical lineToffoli (CCNOT)two filled dots (controls) + one open plus (target)UControlled-Ufilled dot + U box on targetSWAPtwo X marks connected — qubits trade placesMeasurementmeter box — measures qubit in computational basisClassical bit (double line)carries the classical measurement outcome — not a qubit!|0⟩ₐ×Ancilla qubitscratch qubit — prepared in |0⟩, used, discardedtime flows left → right, gates are read in ordersame horizontal position on different wires = simultaneous (parallel)
Every circuit symbol you need to know. Memorise this legend and you can read any quantum circuit on arXiv.

Take a moment with the legend. Each symbol has a single clear meaning. The rest of this chapter is about putting them together.

Wires — the qubit lines

A single horizontal line is one qubit. The label at the left of the line is the input state — typically |0\rangle for a fresh qubit, or |\psi\rangle for an arbitrary state the algorithm has been handed.

Example with three qubits, labelled so you can see the convention:

Three-qubit wire conventionThree horizontal wires labelled ket 0 at left. The top wire is labelled q0, the middle q1, the bottom q2. An arrow below indicates time flowing left to right.|0⟩|0⟩|0⟩q₀q₁q₂startendtime
Three qubits, each starting in $|0\rangle$. The leftmost label is the initial state; the symbol $q_i$ is the qubit's index (not always shown, but implied).

A few notes:

Gates — the boxes

Every gate is drawn as a box or (for multi-qubit gates) a controlled structure.

Single-qubit gates

A single-qubit gate sits as a labelled box on the wire. Standard labels:

Keep box heights consistent — a taller box on one wire is visually confusing.

Controlled gates

A controlled gate has a control qubit and a target qubit (or several of each). The convention:

Multi-controlled gates have multiple filled dots on multiple control wires, all connected to one target. A Toffoli (CCX) has two control dots and one \oplus; a Fredkin (controlled-SWAP) has one control dot and two \times marks.

SWAP

SWAP is drawn as two small \times marks on the two wires, connected by a vertical line. The \times is not a gate label; it is a visual mnemonic for "exchange."

Measurement

Measurement is drawn as a meter-shaped box (a semicircular arc with a diagonal needle) at the end of a wire. The double line exiting the box is a classical wire — it carries a classical bit, not a qubit. If the classical bit feeds back into a later controlled gate (a "classical control"), the double line connects into the relevant location.

Measurement and classical wiresA two-qubit circuit with a CNOT and a measurement on the top qubit, then a classically-controlled X on the bottom qubit. The measurement is drawn as a meter box with a double line exiting to the right, then dropping down to a small X gate box with a vertical double-line connection.X|0⟩|0⟩|ψ'⟩measureclassical bit mif m=1, apply XDouble line = classical wire. X fires only when the measurement outcome was 1.
A CNOT, a measurement of the top qubit, and a classically-controlled $X$ on the bottom qubit — the core of quantum teleportation. The double line from the meter is a classical bit, not a qubit. The $X$ fires only when the classical bit is 1.

This classical-control pattern is the heart of quantum teleportation and measurement-based QC. Recognising the double line is essential.

Reading order — time and matrix

Two different orders matter.

Reading the circuit as time: left to right. The leftmost gate is applied to the input state first; the rightmost is applied last. A circuit with gates U_1, U_2, U_3 drawn left to right means: start with |\psi\rangle, apply U_1, then apply U_2, then apply U_3.

Reading the circuit as a matrix product: right to left. If the gates in the circuit are U_1, U_2, U_3 (in time order), the total unitary is

U_\text{total} \;=\; U_3 \cdot U_2 \cdot U_1.

The last-applied gate sits on the left of the matrix product, because that is how matrix multiplication acts on kets: (U_3 U_2 U_1)|\psi\rangle means "first multiply U_1 into |\psi\rangle, then U_2, then U_3." The leftmost matrix is applied last, even though the leftmost gate in the circuit is drawn first.

Why the two orders differ: matrices act on column vectors from the left. If you want to apply A and then B to |\psi\rangle, you write B(A|\psi\rangle) = BA|\psi\rangle — with B on the left because it is applied second. The circuit diagram arranges gates in time order, but the equivalent matrix expression arranges them in reverse. This is one of the most common mistakes when translating between the two representations — if you write out a matrix product in the same order the circuit is drawn, you get the inverse of the circuit, not the circuit itself.

So when you read a circuit to "extract the matrix," read right to left. When you read a circuit to "simulate the dynamics," read left to right. The picture is the same; the reading direction depends on what you are trying to extract.

Parallelism — gates at the same x-position

Two gates drawn at the same horizontal position on different wires are parallel: they act simultaneously. Because they act on disjoint qubits, they commute (trivially), and the order in which you "apply" them is irrelevant — the tensor product U \otimes V is unambiguous.

Parallel gatesA three-wire circuit with an H gate on the top wire and an X gate on the middle wire at the same horizontal position, labelled simultaneous. Then a CNOT between the top and bottom wires at a later time step.HXtime step 1 (parallel)time step 2|0⟩|0⟩|0⟩
The $H$ on qubit 0 and the $X$ on qubit 1 happen simultaneously (time step 1). The CNOT between qubits 0 and 2 happens later (time step 2). Formally: the first column applies $H \otimes X \otimes I$; the second column applies $\text{CNOT}_{0 \to 2}$.

Parallel gates matter for two reasons:

  1. Circuit depth — the number of time steps — is a proxy for runtime on real hardware. A circuit with many gates but low depth runs faster than one with the same gates in sequence.
  2. Hardware timing — the compiler has to schedule gates to avoid conflicts; parallel gates can share a time slot only if they touch disjoint qubits.

Reading a circuit — an algorithm walkthrough

The quickest way to build circuit fluency is to trace the state at each step. Take the three-qubit GHZ preparation circuit, a classic entanglement generator.

GHZ preparation circuit with state traceA three-wire circuit with an H gate on qubit 0, then a CNOT from qubit 0 to qubit 1, then a CNOT from qubit 1 to qubit 2. Below the circuit, a table with four columns showing the state at the start, after H, after the first CNOT, and after the second CNOT.H|0⟩|0⟩|0⟩|GHZ⟩stagestatestart|000⟩after H on q₀(1/√2)(|000⟩ + |100⟩)after CNOT(0→1)(1/√2)(|000⟩ + |110⟩)after CNOT(1→2)(1/√2)(|000⟩ + |111⟩) = |GHZ⟩
The GHZ preparation circuit: $H$ on qubit 0, then CNOT$_{0\to 1}$, then CNOT$_{1\to 2}$. Tracing the state at each stage produces $|GHZ\rangle = \tfrac{1}{\sqrt 2}(|000\rangle + |111\rangle)$ — a maximally-entangled three-qubit state.

Read the circuit, step by step.

That is it. You have read a circuit. The method — trace the state at each vertical slice, using the gate's action on each basis-state component — is how you read every quantum circuit you will ever see. Do it once carefully, and the rest of circuit-land opens up.

Writing a circuit — the reverse direction

The opposite problem: you have a target unitary or a target output state, and you want to draw the circuit that implements it. This is the compilation direction.

The standard recipe:

  1. Identify the input and output. Write them at the left and right edges.
  2. Decompose the unitary into gates using a known decomposition (e.g., H for superposition, CNOT for entanglement, R_z(\theta) for phase). The chapter on universal gate sets gives the decomposition toolkit.
  3. Draw the gates in time order, left to right.
  4. Verify by tracing the state at each vertical slice; check it matches the target output.

The easiest worked example: a Bell state from |00\rangle. Target: |\Phi^+\rangle = \tfrac{1}{\sqrt 2}(|00\rangle + |11\rangle). The decomposition is H on qubit 0, then CNOT_{0 \to 1}. Draw it: two wires, an H box on the top wire followed by a CNOT with dot on top and \oplus on bottom. Done.

The harder worked example follows below in Example 2.

Example 1 — reading a Deutsch-Jozsa skeleton circuit

The Deutsch-Jozsa algorithm is the paradigmatic "early" quantum algorithm — it determines whether a Boolean function f : \{0,1\}^n \to \{0,1\} is constant or balanced using a single query to f, where any classical algorithm needs 2^{n-1} + 1 queries in the worst case. Its circuit is also a beautiful example of how to read a multi-step quantum circuit. Here is the 3-qubit skeleton (two data qubits and one ancilla for the oracle's output):

Deutsch-Jozsa skeleton circuitA three-wire circuit. Top two wires are the data qubits initialized to ket 0, bottom wire is an ancilla initialized to ket 1. H gates are applied to all three wires at time step 1. A U_f oracle box spans all three wires at time step 2. H gates applied to the top two wires at time step 3. Measurement on the top two wires at time step 4 produces classical outcomes m0 and m1.HHHUfHH|0⟩|0⟩|1⟩m₀m₁q₀q₁ancstep 1: superposestep 2: oracle querystep 3: interferestep 4: measureif all m_i = 0 → f is constant; otherwise f is balanced1 query instead of classical 2^(n-1) + 1
The Deutsch-Jozsa skeleton (2 data qubits + 1 ancilla). Four clear stages: Hadamard setup, one oracle query $U_f$, Hadamard interference, measurement. The whole algorithm is read left to right in four vertical slices.

Step 1 — read the initialisation. Data qubits in |0\rangle. Ancilla in |1\rangle. So the joint state is |0\rangle|0\rangle|1\rangle, or |001\rangle in big-endian order.

Step 2 — read the first time step (three parallel Hs). H on each wire. |0\rangle \to |+\rangle; |1\rangle \to |-\rangle. So after this step:

|+\rangle|+\rangle|-\rangle = \tfrac{1}{\sqrt 8}\sum_{x \in \{0,1\}^2} |x\rangle(|0\rangle - |1\rangle).

Why write it as a sum: this form makes the next step — the oracle query — obvious. The sum over x means the data qubits are in uniform superposition over all 4 input strings; the (|0\rangle - |1\rangle) is the special state that will absorb the oracle's output via phase kickback.

Step 3 — read the oracle U_f in the second time step. The oracle acts as U_f |x\rangle|y\rangle = |x\rangle|y \oplus f(x)\rangle — flips the ancilla if f(x) = 1. On the superposition, the standard phase-kickback computation gives

\tfrac{1}{\sqrt 4}\sum_x (-1)^{f(x)} |x\rangle \otimes \tfrac{1}{\sqrt 2}(|0\rangle - |1\rangle).

The data qubits now carry the phase (-1)^{f(x)} on each |x\rangle; the ancilla has decoupled.

Step 4 — read the second Hadamard layer. Applied to the data qubits only. This takes the phased superposition and interferes it: for f constant, all the (-1)^{f(x)} values are equal, and the Hadamards return the data qubits to |00\rangle. For f balanced, the signs alternate and the Hadamards return the data qubits to something orthogonal to |00\rangle.

Step 5 — read the measurement. Measuring the data qubits tells you whether they are in |00\rangle. If yes (both m_0 = m_1 = 0), f is constant. If no (at least one m_i = 1), f is balanced.

Result. Reading the circuit in 4 time-step slices gives you the whole algorithm: setup, query, interfere, measure. This is the rhythm of every oracular quantum algorithm — the skeleton is the same for Deutsch-Jozsa, Simon, Grover (with amplitude amplification replacing the simple two-H sandwich), and phase-estimation-based algorithms.

The full algebraic details of why the last Hadamard interference works are in the Deutsch-Jozsa chapter. For this chapter, the point is: four time steps, readable in thirty seconds.

Example 2 — writing the Toffoli decomposition from the 6-CNOT recipe

Turn the arrow around. You have the Toffoli gate — a three-qubit controlled-controlled-NOT — and you want to draw its standard decomposition into single-qubit gates and CNOTs. The well-known result: Toffoli decomposes into 6 CNOTs and 9 single-qubit gates.

The recipe:

  1. H on qubit 2 (the target).
  2. CNOT from qubit 1 to qubit 2.
  3. T^\dagger on qubit 2.
  4. CNOT from qubit 0 to qubit 2.
  5. T on qubit 2.
  6. CNOT from qubit 1 to qubit 2.
  7. T^\dagger on qubit 2.
  8. CNOT from qubit 0 to qubit 2.
  9. T on qubits 1 and 2; T^\dagger on qubit 0.
  10. CNOT from qubit 0 to qubit 1.
  11. T^\dagger on qubit 1; T on qubit 0.
  12. CNOT from qubit 0 to qubit 1.
  13. H on qubit 2.

(Single-qubit gates and CNOTs, interleaved. Count them: 6 CNOTs, and the rest are single-qubit gates. The detailed proof that this is Toffoli is in the Toffoli gate chapter.)

Step 1 — draw the three wires. Three horizontal lines, labelled |a\rangle, |b\rangle, |c\rangle at the left — the two controls and the target.

Step 2 — walk through each step of the recipe and place the gate. Each CNOT is a dot-and-\oplus; each T or T^\dagger is a labelled box. Space them evenly.

Step 3 — label the output. After the whole sequence, the output is |a\rangle|b\rangle|c \oplus ab\rangle — which is the Toffoli's action.

Toffoli decomposition — 6 CNOTs and 9 single-qubit gatesA three-wire circuit showing the explicit Toffoli decomposition. The top wire is control a, middle is control b, bottom is target c with an H gate at both ends. Between the H gates there are alternating CNOTs and T or T-dagger gates on various wires. The output is labelled a, b, c XOR ab.HT†TT†T†TTTT†H|a⟩|b⟩|c⟩|a⟩|b⟩|c⊕ab⟩6 CNOTs + 9 single-qubit gates = one ToffoliThis is the standard compilation target for any fault-tolerant Toffoli.
The Toffoli gate drawn as its explicit 6-CNOT, 9-single-qubit-gate decomposition. Read left to right, each vertical slice is one time step. The outer $H$s on qubit 2 transform the problem from "flip the target when ab=1" into a phase problem that the $T$/$T^\dagger$ chain solves.

Result. A circuit you can draw from scratch starting from the gate list. And once drawn, it compiles directly to any hardware that offers \{H, T, \text{CNOT}\} — which is every fault-tolerant architecture on the planet.

Drawing circuits from decompositions is the bread-and-butter of quantum-algorithm paper-writing. Whenever you read "we implement this primitive with cost 6 CNOTs and 9 single-qubit gates," this is the diagram they mean.

Common confusions

Going deeper

If you are here to learn to read quantum circuit diagrams, you have it — the basics above cover almost every circuit you will meet on arXiv or in a textbook. The rest of this chapter surveys circuit optimisation, the ZX calculus (a graphical rewriting system that extends circuit diagrams), transpilation in real quantum compilers, and the tooling that lets you move between circuits and code.

ZX calculus — a more powerful graphical language

The ZX calculus (Coecke-Duncan 2008, Backens 2014) is a formal graphical language that extends circuit diagrams with rewrite rules that can prove circuit equivalences by local graph manipulations. In ZX, each gate becomes a spider — a node labelled with a phase — and wires connect spiders. Green spiders represent the Z basis (phase gates); red spiders represent the X basis (Hadamard-conjugated phase gates). The rewrite rules are a small finite set (the spider fusion rule, the colour change rule, and a few others), and they are complete for Clifford+T circuits — every true circuit equivalence is provable by ZX rewriting.

ZX calculus is the engine behind several modern quantum compilers (Quantinuum's TKET, PyZX for ZX-based optimisation), and it is the single most powerful tool for discovering new circuit optimisations. The chapter circuit identities covers ZX briefly; a full treatment needs its own curriculum track.

Ordinary circuit diagrams are sufficient but often inefficient. ZX is strictly more expressive for optimisation, because it can "forget" the time-ordering of commuting gates and re-order them freely.

Transpilation in real compilers

When you submit a Qiskit program to IBM Quantum, you do not get to run your circuit as written. The compiler (transpiler) rewrites it to match the target backend's constraints:

  1. Gate decomposition — every gate is rewritten into the backend's native set (e.g., \{R_z(\theta), \sqrt X, \text{CNOT}\} on IBM hardware). This is the Solovay-Kitaev + KAK decomposition from the universal gate sets chapter.
  2. Qubit routing — since not all qubit pairs are physically connected on the chip, the transpiler inserts SWAP gates to move logical qubits to physically-coupled positions. This is usually the dominant source of extra gate count.
  3. Gate cancellation — consecutive gates that cancel (like two Hadamards in a row = identity) are removed.
  4. Scheduling — gates are assigned to time slots to maximise parallelism.

The output is a circuit that looks very different from your input but implements the same unitary (approximately). Qiskit's transpile(circ, backend, optimization_level=3) runs the full pipeline. Reading the transpiled output is a useful skill: it teaches you what your circuit "really" costs on hardware.

Circuit drawing tools — ASCII, Qcircuit, Quantikz

Different papers and tools use different rendering:

If you want to write a quantum paper, learn Quantikz. If you want to prototype, use Qiskit's draw('mpl'). If you want publication-quality figures for a blog or wiki, write SVG by hand (which is what we do here).

Measurement-based QC circuit conventions

In the measurement-based quantum computing model, circuits look very different:

Measurement-based circuits are drawn as grids of qubits with arrows showing measurement angles and the adaptive-dependency flow. They are universal (equivalent to the circuit model), but the diagrammatic conventions are entirely different. If you encounter a measurement-based paper, do not expect the notation here to apply directly; MBQC has its own visual language.

Classical-control and mid-circuit measurement

Modern hardware (IBM Heron, Quantinuum H2) supports mid-circuit measurement — measuring a qubit partway through a circuit, using the classical outcome to condition later gates, and then continuing to use other qubits. This is drawn with a measurement box mid-circuit, a double line for the classical outcome, and a classically-conditioned gate (a gate box with a classical input line entering from above or below).

The classical-control pattern is essential for:

The relevant figure in this chapter — the CNOT-measure-classical-control diagram — shows the basic pattern. Every more complex classical-control diagram is built out of this primitive.

Where this leads next

References

  1. Nielsen and Chuang, Quantum Computation and Quantum Information (2010), §4.2 (circuit model and notation) — Cambridge University Press.
  2. John Preskill, Lecture Notes on Quantum Computation, Ch. 6 (circuit model and universality) — theory.caltech.edu/~preskill/ph229.
  3. Alastair Kay, Tutorial on the Quantikz Package — the standard LaTeX circuit-drawing toolkit, with examples. arXiv:1809.03842.
  4. Qiskit Textbook, Representing Qubit States and subsequent gate chapters — circuits drawn and explained with runnable Qiskit code.
  5. Bob Coecke and Ross Duncan, Interacting Quantum Observables: Categorical Algebra and Diagrammatics (2011) — the foundational ZX-calculus paper. arXiv:0906.4725.
  6. Wikipedia, Quantum circuit — a concise summary of the notation and standard examples.