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:
- One horizontal wire per qubit. A circuit with n wires describes a system of n qubits.
- Time flows from left to right. The input state sits at the left edge; the output at the right.
- 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.
- Two gates at the same horizontal position on different wires happen in parallel. They act simultaneously on their respective qubits.
- 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.
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:
A few notes:
- If the input is not a computational-basis state, label it explicitly: |\psi\rangle, |+\rangle, \tfrac{1}{\sqrt 2}(|0\rangle + |1\rangle).
- If a wire is an ancilla (a scratch qubit that will be prepared in |0\rangle, used internally, and discarded), label it |0\rangle_a or simply "ancilla." Some conventions draw ancilla wires as dashed lines.
- The qubit index q_0, q_1, q_2, \ldots is ordered top to bottom in the Nielsen & Chuang convention (the one this wiki uses). Qiskit uses the reverse: the top wire in Qiskit's default drawing is the least-significant qubit — i.e., q_0 at the top corresponds to bit 0, which is the rightmost character when you write computational-basis kets like |q_2 q_1 q_0\rangle. This is a genuine confusion-magnet; more on it in "Common confusions" below.
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:
- H for Hadamard
- X, Y, Z for Pauli gates
- S, S^\dagger for the phase gate and its inverse
- T, T^\dagger for the \pi/8 gate and its inverse
- R_x(\theta), R_y(\theta), R_z(\theta) for continuous rotations (label the angle)
- U or U(\alpha, \beta, \gamma) for a generic single-qubit unitary with its three parameters
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:
- Filled dot on the control wire: the gate fires when this qubit is |1\rangle.
- Open (empty) dot: the gate fires when this qubit is |0\rangle. Less common, but used.
- Vertical line connects control to target.
- Target symbol: \oplus (open circle with plus) for CNOT, or a labelled box for controlled-U.
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.
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
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 gates matter for two reasons:
- 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.
- 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.
Read the circuit, step by step.
- Start. All three qubits in |0\rangle: |000\rangle.
- Time step 1 — H on qubit 0. Turns |0\rangle into |+\rangle = \tfrac{1}{\sqrt 2}(|0\rangle + |1\rangle) on qubit 0, leaves qubits 1 and 2 alone. State: \tfrac{1}{\sqrt 2}(|000\rangle + |100\rangle).
- Time step 2 — CNOT from qubit 0 to qubit 1. Where qubit 0 is 0, leave qubit 1 alone; where qubit 0 is 1, flip qubit 1. First term: |000\rangle \to |000\rangle. Second term: |100\rangle \to |110\rangle. State: \tfrac{1}{\sqrt 2}(|000\rangle + |110\rangle).
- Time step 3 — CNOT from qubit 1 to qubit 2. Where qubit 1 is 0, leave qubit 2 alone; where qubit 1 is 1, flip qubit 2. First term: |000\rangle \to |000\rangle. Second term: |110\rangle \to |111\rangle. State: \tfrac{1}{\sqrt 2}(|000\rangle + |111\rangle) = |GHZ\rangle.
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:
- Identify the input and output. Write them at the left and right edges.
- 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.
- Draw the gates in time order, left to right.
- 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):
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:
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
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:
- H on qubit 2 (the target).
- CNOT from qubit 1 to qubit 2.
- T^\dagger on qubit 2.
- CNOT from qubit 0 to qubit 2.
- T on qubit 2.
- CNOT from qubit 1 to qubit 2.
- T^\dagger on qubit 2.
- CNOT from qubit 0 to qubit 2.
- T on qubits 1 and 2; T^\dagger on qubit 0.
- CNOT from qubit 0 to qubit 1.
- T^\dagger on qubit 1; T on qubit 0.
- CNOT from qubit 0 to qubit 1.
- 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.
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
-
Qiskit vs Nielsen & Chuang qubit ordering. N&C (and this wiki) use top-to-bottom = q_0, q_1, q_2, \ldots with q_0 the most-significant qubit when writing kets like |q_0 q_1 q_2\rangle. Qiskit uses top-to-bottom = q_0, q_1, q_2, \ldots but q_0 is the least-significant qubit — so Qiskit writes the same state as |q_2 q_1 q_0\rangle, i.e., the top wire is the rightmost character in the ket. Same picture, opposite ket-string order. If you are reading a Qiskit-generated circuit and the state strings look "mirrored," this is why. Always check the paper's convention.
-
Time order vs matrix order. Reading left-to-right in time means the leftmost gate is applied first. Reading as a matrix product, the leftmost gate is on the right of the product — because matrices act on the ket from the left, so the first-applied matrix is the rightmost in the product. Circuit [U_1, U_2, U_3] drawn left-to-right equals matrix product U_3 U_2 U_1.
-
Parallel gates are simultaneous, not commutative "by coincidence." Gates drawn at the same horizontal position on different wires always commute (they act on disjoint qubits, so U \otimes V = V \otimes U as tensor products). Gates on the same wire at different horizontal positions generally do not commute — their order matters.
-
Classical wires are drawn as double lines to distinguish them from quantum wires. A single horizontal line is a qubit; a double horizontal line is a classical bit. Mixing them up makes a circuit look impossible — "how does a measurement's output feed back into a gate?" Answer: via a classical double-line, not a quantum wire. The quantum wire is destroyed by the measurement.
-
Ancilla qubits are qubits, not classical registers. An ancilla is a scratch qubit, drawn as a standard quantum wire. It is typically labelled |0\rangle at the left and "discarded" or "uncomputed to |0\rangle" at the right. The "ancilla" label is a role, not a different kind of wire.
-
Gate order inside a box. Some papers compress a sequence of single-qubit gates on one wire into a single multi-gate label, e.g., "HSH" inside one box. Read the sequence inside the box left-to-right as the order of application, same as outside. Some other papers use "(HSH)" in the form (\text{outer})(\text{middle})(\text{inner}) order (matching matrix multiplication). Always check.
-
Measurement arrows and bases. Some papers decorate measurements with a basis label (a Z for computational basis, an X for Pauli-X basis, etc.) inside or above the meter box. If unlabelled, default to the computational basis. In measurement-based QC papers, measurement basis angles matter and are always labelled explicitly.
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:
- 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.
- 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.
- Gate cancellation — consecutive gates that cancel (like two Hadamards in a row = identity) are removed.
- 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:
- ASCII art — old-school, still common in textbooks. Uses
──,├,┼,○,●,⊕, and similar characters. Readable but ugly. - LaTeX Qcircuit — the most common paper-quality tool. A TikZ-based package with commands like
\ctrl{1},\targ,\gate{H},\meter. Used in most arXiv quantum-computing papers written before 2020. - LaTeX Quantikz — the successor to Qcircuit. Cleaner syntax, better spacing. The current standard as of 2025.
- Qiskit's
circuit.draw()— renders to ASCII, matplotlib, or LaTeX. Default ASCII output is nearly unreadable; usedraw('mpl')for matplotlib ordraw('latex_source')for LaTeX. - Cirq's
SVGCircuit— web-friendly SVG renders. - This wiki's hand-written SVG — the cleanest rendering for web, and what every figure in this chapter uses.
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:
- The "circuit" is a large cluster state — a specific entangled state with qubits arranged on a grid, pre-prepared.
- Computation is a sequence of measurements in adaptive bases, one qubit at a time.
- Each measurement's basis angle depends on the outcome of previous measurements.
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:
- Quantum teleportation (the outcome of a Bell measurement classically conditions a Pauli correction on the target qubit).
- Quantum error correction (syndrome measurements classically condition error-correction operations).
- Measurement-based QC (every measurement's basis depends on previous outcomes).
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
- Circuit identities — equivalences between circuits (H X H = Z, CNOT_{1 \to 0} = (H \otimes H) CNOT_{0 \to 1} (H \otimes H), etc.), the basic lemmas of circuit manipulation.
- Universal gate sets — the finite gate sets (\{H, S, \text{CNOT}, T\}, etc.) into which any circuit is eventually compiled.
- Ancilla qubits — scratch qubits that make many algorithms possible; how to prepare, use, and uncompute them.
- Quantum teleportation — the canonical circuit combining entanglement, measurement, and classical control. A masterclass in circuit reading.
- CNOT gate — the workhorse two-qubit gate, the most common non-trivial symbol in any circuit.
- Measurement in arbitrary bases — how to read and write measurements in non-computational bases.
References
- Nielsen and Chuang, Quantum Computation and Quantum Information (2010), §4.2 (circuit model and notation) — Cambridge University Press.
- John Preskill, Lecture Notes on Quantum Computation, Ch. 6 (circuit model and universality) — theory.caltech.edu/~preskill/ph229.
- Alastair Kay, Tutorial on the Quantikz Package — the standard LaTeX circuit-drawing toolkit, with examples. arXiv:1809.03842.
- Qiskit Textbook, Representing Qubit States and subsequent gate chapters — circuits drawn and explained with runnable Qiskit code.
- Bob Coecke and Ross Duncan, Interacting Quantum Observables: Categorical Algebra and Diagrammatics (2011) — the foundational ZX-calculus paper. arXiv:0906.4725.
- Wikipedia, Quantum circuit — a concise summary of the notation and standard examples.