Quantum Gates Cheat Sheet: X, Y, Z, H, S, T, CNOT, CZ, and SWAP Explained
quantum gatesqubit basicsreferencedeveloper guide

Quantum Gates Cheat Sheet: X, Y, Z, H, S, T, CNOT, CZ, and SWAP Explained

SSmart Qubit Labs Editorial
2026-06-08
10 min read

A practical cheat sheet for understanding X, Y, Z, H, S, T, CNOT, CZ, and SWAP gates across quantum SDKs and beginner workflows.

If you write or review quantum circuits, the fastest way to get unstuck is usually not another long theory lesson. It is a clear mental model of what the common gates actually do, when two gates are effectively interchangeable, and which gate to reach for in a practical workflow. This cheat sheet is a developer-friendly reference to the core single-qubit and two-qubit gates you will meet in almost every quantum computing tutorial, from Qiskit and IBM Quantum examples to Cirq, PennyLane, Azure Quantum, and Amazon Braket workflows. It explains X, Y, Z, H, S, T, CNOT, CZ, and SWAP with matrix intuition, plain-English behaviour, common use cases, and a few comparison rules that make circuit reading much easier.

Overview

This guide gives you a compact reference for the gates most beginners and working developers use first. The aim is not to turn gate notation into abstract linear algebra trivia. It is to help you read circuits, debug simple algorithms, and move more confidently between quantum SDKs.

At a high level, quantum gates are operations applied to qubits. Like logic gates in classical computing, they change state, but the comparison only goes so far. A classical bit is either 0 or 1. A qubit can sit in a superposition, which means its state is described by amplitudes rather than a single binary value. Gates therefore do more than flip a bit: they rotate the qubit state, change phase, or create correlations between qubits that lead to entanglement.

For quick orientation, the gates in this article break into three useful groups:

  • Bit-flip style gates: X acts most like a NOT gate.
  • Phase gates: Z, S, and T mainly change phase rather than measured bit values directly.
  • Basis-changing and entangling gates: H, CNOT, CZ, and SWAP help prepare superposition, control interactions, or rearrange qubits in a circuit.

One practical note for quantum computing for beginners: many early mistakes come from assuming a gate has done nothing because the measurement result looks unchanged. Phase gates are the classic example. A Z gate can leave computational-basis measurement probabilities unchanged while still being very important for the next part of the circuit.

How to compare options

When you compare quantum gates, do not start with the matrix unless you need exact derivations. Start with four developer-focused questions.

1. Does the gate change the measured bit value or only the phase?

X changes |0⟩ to |1⟩ and |1⟩ to |0⟩, so its effect is immediately visible in a simple measurement. Z does not swap those basis states. Instead, it changes the relative phase of |1⟩. That phase matters when later gates interfere amplitudes.

2. Is the gate single-qubit or two-qubit?

Single-qubit gates are easier to reason about in isolation. Two-qubit gates are where circuits begin to express useful structure, including entanglement. If a circuit contains only single-qubit gates, each qubit evolves independently. As soon as you add gates like CNOT or CZ, the qubits can become correlated in a way classical bits cannot.

3. Is the gate mainly changing basis, adding phase, or conditioning one qubit on another?

Hadamard is the classic basis-changing gate. S and T are phase gates. CNOT and CZ are controlled two-qubit gates. SWAP changes placement rather than logic in the usual sense. This classification is often more useful than memorising matrices one by one.

4. Is the difference operational or just representational?

Some gates are distinct mathematically but play similar practical roles depending on the basis you work in. The most useful example is CZ gate vs CNOT. They are not the same gate, but you can transform one into the other by surrounding the target qubit with Hadamard gates. That makes them closely related in many circuit constructions.

A useful comparison checklist for any quantum SDK guide or circuit review is:

  • What basis is the qubit currently in?
  • Will the gate alter amplitude, phase, or both?
  • Will the effect show up immediately in measurement, or only after interference?
  • Does the hardware or compiler prefer one entangling pattern over another?
  • Are you using the gate for algorithm logic or just for routing qubits into place?

If you want to see these ideas inside a fuller developer workflow, the Qiskit tutorial for UK developers is a good next step.

Feature-by-feature breakdown

Below is the cheat sheet itself: what each gate does, what its matrix suggests, and where it commonly appears.

X gate

What it does: The X gate flips a qubit between |0⟩ and |1⟩. It is the closest quantum equivalent to a classical NOT gate.

Matrix intuition: The X matrix swaps the two basis amplitudes. If your qubit is definitely 0, it becomes definitely 1. If it is in superposition, the amplitudes are exchanged.

Why it matters: X is often the first gate used in any quantum gates tutorial because it is easy to verify with measurement. It is also used to prepare a control qubit in the |1⟩ state before applying controlled operations.

Common use cases:

  • Initial state preparation
  • Testing measurement paths
  • Constructing more complex logic with controlled gates

Y gate

What it does: Y also flips |0⟩ and |1⟩, but with an added phase factor. It combines a bit flip and a phase change.

Matrix intuition: Think of Y as similar to X, but with an imaginary phase built in. This makes it less intuitive for beginners and more useful when thinking in terms of rotations on the Bloch sphere.

Why it matters: Y appears less often in simple beginner circuits than X or Z, but it is important for describing general rotations, state preparation, and certain Hamiltonians in simulation work.

Common use cases:

  • Rotation decompositions
  • Physics-inspired circuits
  • Expectation calculations involving Pauli operators

Z gate

What it does: Z leaves |0⟩ unchanged and flips the phase of |1⟩.

Matrix intuition: The amplitudes are not swapped. Instead, the sign of the |1⟩ component changes. That can look invisible until another gate, often H, converts phase information into measurable probability differences.

Why it matters: If you are learning qubits explained or superposition explained, Z is one of the key reasons interference matters. It teaches the difference between state labels and phase relationships.

Common use cases:

  • Phase kickback patterns
  • Error models and stabiliser thinking
  • Building controlled-phase logic

H gate

What it does: The Hadamard gate takes basis states into equal superpositions and back again. Applied to |0⟩, it creates a state with equal amplitude for 0 and 1. Applied again, it reverses that change.

Matrix intuition: H mixes amplitudes and changes basis. It is the gate that makes many quantum circuits look non-classical, because it creates the possibility for interference.

Why it matters: H is central to most quantum computing tutorials, from toy examples to algorithm design. Without basis changes, phase information often stays hidden.

Common use cases:

  • Creating superposition
  • Moving between X-basis and Z-basis viewpoints
  • Turning phase differences into measurement differences

S gate

What it does: S is a phase gate that applies a quarter-turn phase to the |1⟩ component.

Matrix intuition: It is a milder phase shift than Z in the sense that applying S twice gives Z. That makes S useful to think of as a square root of Z.

Why it matters: S shows up in gate decompositions, Clifford circuits, and error-correction discussions. It is often one of the first examples of a gate whose importance is more algebraic than visually obvious in simple measurement tests.

Common use cases:

  • Phase correction
  • Compiler decompositions
  • Clifford circuit construction

T gate

What it does: T is another phase gate, smaller than S. Applying T twice gives S, and four times gives Z.

Matrix intuition: T applies an eighth-turn phase to the |1⟩ amplitude. It is a simple gate with outsized importance in fault-tolerant and universal gate discussions.

Why it matters: In many theoretical and practical conversations, the T gate matters because adding it to the Clifford gate set gives computational universality. You do not need full fault-tolerance theory to understand the practical lesson: T is one of the gates that pushes a basic instruction set into a much richer one.

Common use cases:

  • Universal gate set constructions
  • Circuit synthesis
  • Resource estimates in advanced workflows

CNOT gate

What it does: The controlled-NOT, or CNOT, flips the target qubit if the control qubit is |1⟩.

Matrix intuition: On two qubits, most basis states pass through unchanged except the pair where the control is 1; there, the target is toggled.

Why it matters: CNOT gate explained in one line: it is the standard gateway from independent qubits to entangled states. A Hadamard on one qubit followed by CNOT is the classic Bell-state pattern.

Common use cases:

  • Creating entanglement
  • Conditioning one qubit on another
  • Parity logic and algorithm subroutines

CZ gate

What it does: CZ applies a Z phase flip to the target when the control is |1⟩. Equivalently, it changes the sign of the |11⟩ state amplitude.

Matrix intuition: Unlike CNOT, CZ is diagonal in the computational basis. Nothing gets swapped. Only one basis component picks up a negative sign.

Why it matters: The practical discussion of CZ gate vs CNOT comes up often because both are common entangling gates, but they feel different when you read a circuit. CNOT looks like conditional bit logic. CZ looks like conditional phase logic. They are closely related by basis change: applying H before and after the target converts between them.

Common use cases:

  • Controlled-phase constructions
  • Hardware-native entangling layers on some platforms
  • Graph-state and variational circuit patterns

SWAP gate

What it does: SWAP exchanges the states of two qubits.

Matrix intuition: It leaves |00⟩ and |11⟩ alone but exchanges |01⟩ and |10⟩.

Why it matters: SWAP gate quantum discussions are often about hardware layout, not algorithm novelty. On many devices, qubits can only interact with certain neighbours. SWAP gates help move quantum information into positions where the required two-qubit gate can be executed.

Common use cases:

  • Routing on constrained hardware topologies
  • Reordering logical qubits
  • Compiler transformations

A useful warning for developers: SWAP often appears because of device constraints, not because the original algorithm asked for it. This is one reason transpilation and hardware mapping matter, especially in enterprise quantum computing experiments where depth and error rates can dominate outcomes. For more context, see Qubit Quality in the Real World.

Best fit by scenario

If you are choosing gates while building or reading circuits, the best option depends on the job.

You want a visible bit flip

Use X. If you want the quantum circuit simulator output to change in a direct, easy-to-check way, X is the cleanest choice.

You want to create superposition

Use H. This is usually the first step in showing non-classical behaviour.

You want to change phase without immediately changing measurement counts

Use Z, S, or T depending on how much phase you need and what gate set you are working with.

You want to create entanglement quickly

Use H + CNOT as your default mental model. It is still one of the simplest examples for entanglement explained.

You are comparing CZ and CNOT

Pick the gate that matches your hardware, compiler, or circuit readability needs. If your circuit is easier to think about as conditional bit-flip logic, CNOT is often clearer. If you are working in phase-based constructions or hardware that naturally uses controlled-phase operations, CZ may be the better fit.

You need qubits to interact but they are not adjacent

Use SWAP when routing demands it, but treat it as a cost to minimise. Extra SWAPs can increase circuit depth and error exposure.

You are studying universal gate sets or compilation

Pay close attention to H, S, T, and CNOT. These gates come up repeatedly in decompositions and practical toolchains.

For teams moving from tutorials toward pilot use cases, it helps to connect gate-level understanding with application-level realism. These related reads may help:

When to revisit

This is a stable topic, but it is worth revisiting when the surrounding tools and platforms change. The gates themselves are foundational. What changes over time is how SDKs expose them, how compilers rewrite them, and which native two-qubit operations matter most on specific cloud backends.

Come back to this cheat sheet when:

  • You switch from one framework to another, such as from a Qiskit tutorial to a Cirq or PennyLane workflow.
  • You start running on real hardware rather than only a simulator.
  • You notice transpilation introducing unexpected SWAPs or rewriting entangling gates.
  • You are comparing IBM Quantum, Azure Quantum, or Amazon Braket tooling and need a gate-level mental model that survives platform differences.
  • You move from beginner demos into variational algorithms, optimisation workflows, or hybrid quantum classical computing.

A practical refresh routine is simple:

  1. Rebuild one Bell-state circuit using H and CNOT.
  2. Rewrite it using CZ plus Hadamards around the target.
  3. Inspect any transpiled version to see what the compiler changed.
  4. Run the same circuit on a simulator and, if available, a hardware backend.
  5. Note which gates were logical choices and which were routing or hardware choices.

That small exercise will improve your intuition faster than memorising matrices in isolation.

Finally, if you are building internal capability rather than just learning for curiosity, keep gate knowledge connected to tooling, hardware realities, and security planning. Smart teams revisit fundamentals not because the basics change, but because the environment around them does. For broader context, see What the Quantum Market Numbers Miss, Beyond the Hype Cycle, and Quantum Security for Cloud and Network Teams.

If you keep one takeaway from this reference, make it this: X changes values, Z changes phase, H changes basis, CNOT and CZ create structured two-qubit behaviour, and SWAP moves information into place. Once that mental map is clear, most beginner circuits become much easier to read, compare, and debug.

Related Topics

#quantum gates#qubit basics#reference#developer guide
S

Smart Qubit Labs Editorial

Editorial Team

Senior editor and content strategist. Writing about technology, design, and the future of digital media. Follow along for deep dives into the industry's moving parts.

2026-06-10T03:36:48.577Z