An Interactive Quantum Circuit Playground
Quantum gates are the operations of quantum computing - the building blocks that transform qubit states. A quantum circuit is a sequence of these gates applied in order. Understanding the common gates is the key to reading and writing quantum programs.
Every single-qubit gate corresponds to a rotation of the Bloch sphere. This is not an approximation - it is exact. Every valid single-qubit quantum operation rotates the Bloch vector by some angle around some axis. Different gates correspond to different rotations.
This geometric picture is powerful. It means you can understand what any gate does by asking: which direction does it rotate the state, and by how much? It also explains why H applied twice cancels: you rotate 180° and then 180° again, returning to the start. And it explains why gates are reversible - rotation in one direction can always be undone by rotation in the opposite direction. Think of it like turning a steering wheel: turn it 90° left, then 90° right, and the wheel is back where it started - no information about the trip is lost.
Click any gate card to see a deeper explanation. Each gate is a precise rotation of the Bloch sphere.
Single-qubit gates rotate one qubit. Two-qubit gates create correlations between two qubits - and entanglement. The most important two-qubit gate is the CNOT (Controlled-NOT). It has a control qubit and a target qubit: if the control is |1⟩, the target is flipped; if the control is |0⟩, nothing happens.
Other important two-qubit gates include the SWAP gate, which exchanges the states of two qubits. In the Sandbox's expert mode, you will also encounter the Toffoli gate (CCNOT) - a three-qubit gate that flips the target only when both controls are |1⟩, like a light switch that only turns on when two separate keys are both turned at once. The Toffoli gate makes the quantum gate set computationally universal, meaning it can simulate any classical logical operation.
Just as classical computing can implement any logic using only NAND gates, quantum computing can implement any quantum operation using a small set of universal gates. One universal set is {H, T, CNOT}. Every quantum algorithm can be decomposed into some sequence of these three gate types.
This matters practically: when a quantum chip only natively supports a few gate types, any arbitrary gate can be approximated to arbitrary precision using sequences of those native gates - similar to how a few standard LEGO bricks can be combined to approximate almost any shape, even curves they were never molded to make directly. The Solovay-Kitaev theorem guarantees that this approximation is efficient - you do not need exponentially many gates to approximate a complex rotation.
It's worth being precise about what "universal" means here: it does not mean these are the only gates that exist. Mathematically, any unitary matrix is a valid quantum gate, and rotation angles are continuous - so there are infinitely many possible gates, most of which never get a name. The named gates in this lesson (and in the Sandbox's Gate Library) are simply a small, practical set that real algorithms are commonly built from. A "universal" set is just powerful enough to reach any of those infinite possibilities through composition, the same way infinite shades of color can be mixed from a handful of primary pigments.
Here is how gates compose into a real quantum circuit. This two-step sequence creates the simplest maximally entangled state - called a Bell state. Follow the flow:
Quantum circuits are typically drawn as horizontal lines (one per qubit) with gate symbols placed on them. Time flows left to right. Single-qubit gates are boxes on one wire. Two-qubit gates span two wires and show a connection between them.
The circuit depth is the number of columns - the longest path through the circuit. The width is the number of qubits. Total gate count tells you roughly how many operations the quantum computer must perform. All three metrics matter for real hardware: more depth means more decoherence time, and more gates means more opportunities for error.
When you design a quantum circuit, you are balancing expressiveness (doing what you need computationally) against resource efficiency (keeping depth and gate count low enough to stay within the hardware's error budget). This optimization is one of the core skills of quantum programming.
On real hardware, every gate is implemented as a carefully timed pulse of microwave radiation (for superconducting qubits) or a laser pulse (for trapped ions). These pulses are not perfect - they introduce small errors. Gate fidelity measures how close to perfect a gate operation is: a fidelity of 99.9% means the gate introduces a 0.1% error probability on average.
Quantum circuit compilation is the process of taking a high-level circuit description and translating it to the specific native gates of a particular hardware chip, while also mapping logical qubits to physical qubits (accounting for which qubits are connected to each other). It's a bit like translating a recipe written for a professional kitchen into one a home cook can follow with a smaller set of pots, pans, and ingredients - some steps combine, others expand, and the order may have to change. This compilation step can dramatically increase or decrease the final gate count, which is why quantum software tools like Qiskit and Cirq spend significant effort on circuit optimization.
Quantum gates are rotations of the Bloch sphere. Single-qubit gates (X, Y, Z, H, S, T) manipulate one qubit's state. Two-qubit gates (CNOT, SWAP) create entanglement. The set {H, T, CNOT} is universal - any quantum computation can be built from these three types alone.
Why does applying the Hadamard (H) gate twice in a row to a qubit return it to its original state?
What is the effect of applying the Z gate to a qubit that is in perfect 50/50 superposition, then measuring it?
In a CNOT gate, what determines whether the target qubit gets flipped?
Which combination of gates is commonly described as a "universal gate set" for quantum computing?
In a quantum circuit diagram, what does "circuit depth" refer to?