Quantum Circuit Converter
Turn one circuit into code for Qiskit, Cirq, PennyLane and OpenQASM. Start from an example or from your Circuit Builder circuit, see the exact outcome chances, copy the code, or paste QASM or Qiskit code to read it back. Includes a gate cheat sheet and a bit-order guide.
Reviewed December 2026. New to this? Pick the Bell state example and flip between the five tabs.
from qiskit import QuantumCircuit, transpile from qiskit_aer import AerSimulator from math import pi qc = QuantumCircuit(1, 1) qc.h(0) qc.measure(0, 0) sim = AerSimulator() counts = sim.run(transpile(qc, sim), shots=1000).result().get_counts() print(counts) # Measurements are moved to the end of the circuit. # Qiskit writes bit strings with qubit 0 on the RIGHT. This site writes qubit 0 on the LEFT.
The circuit
q0: |0⟩──H──M──
Exact outcome chances, in this site’s order (qubit 0 on the left)
A five-minute path
- Convert tab: choose the Bell state example. Read the Qiskit code, then switch to Cirq and PennyLane.
- Choose an example with a rotation gate. See how each tool writes the angle.
- Bit order tab: type 100 and see why Qiskit shows 001.
- Paste code tab: edit the sample OpenQASM and watch the circuit and probabilities change.
- Click “Open in Circuit Builder” to continue editing the pasted circuit.
- Run the generated code in your own installation and compare to the exact chances.
What the converter does and does not do
- It maps each gate one for one and writes text. It does not run any framework.
- The importer reads OpenQASM 2.0 and simple Qiskit code, up to 5 qubits and 16 columns.
- Measurements move to the end. Mid-circuit measurement and classical control are not supported.
- It does not compile for hardware or add noise.
Reference tables
Produced by the same functions as the converter.
| Gate | Qiskit | Cirq | PennyLane | OpenQASM 2.0 | OpenQASM 3.0 |
|---|---|---|---|---|---|
| Hadamard | qc.h(0) | cirq.H(q[0]) | qml.Hadamard(wires=0) | h q[0]; | h q[0]; |
| Pauli X | qc.x(0) | cirq.X(q[0]) | qml.PauliX(wires=0) | x q[0]; | x q[0]; |
| Pauli Y | qc.y(0) | cirq.Y(q[0]) | qml.PauliY(wires=0) | y q[0]; | y q[0]; |
| Pauli Z | qc.z(0) | cirq.Z(q[0]) | qml.PauliZ(wires=0) | z q[0]; | z q[0]; |
| S (quarter turn) | qc.s(0) | cirq.S(q[0]) | qml.S(wires=0) | s q[0]; | s q[0]; |
| S dagger | qc.sdg(0) | cirq.S(q[0]) ** -1 | qml.adjoint(qml.S)(wires=0) | sdg q[0]; | sdg q[0]; |
| T (eighth turn) | qc.t(0) | cirq.T(q[0]) | qml.T(wires=0) | t q[0]; | t q[0]; |
| T dagger | qc.tdg(0) | cirq.T(q[0]) ** -1 | qml.adjoint(qml.T)(wires=0) | tdg q[0]; | tdg q[0]; |
| Rotation about X | qc.rx(θ, 0) | cirq.rx(θ)(q[0]) | qml.RX(θ, wires=0) | rx(θ) q[0]; | rx(θ) q[0]; |
| Rotation about Y | qc.ry(θ, 0) | cirq.ry(θ)(q[0]) | qml.RY(θ, wires=0) | ry(θ) q[0]; | ry(θ) q[0]; |
| Rotation about Z | qc.rz(θ, 0) | cirq.rz(θ)(q[0]) | qml.RZ(θ, wires=0) | rz(θ) q[0]; | rz(θ) q[0]; |
| CNOT | qc.cx(0, 1) | cirq.CNOT(q[0], q[1]) | qml.CNOT(wires=[0, 1]) | cx q[0], q[1]; | cx q[0], q[1]; |
| Controlled Z | qc.cz(0, 1) | cirq.CZ(q[0], q[1]) | qml.CZ(wires=[0, 1]) | cz q[0], q[1]; | cz q[0], q[1]; |
| Controlled phase | qc.cp(θ, 0, 1) | cirq.CZ(q[0], q[1]) ** (θ / pi) | qml.ControlledPhaseShift(θ, wires=[0, 1]) | cu1(θ) q[0], q[1]; | cp(θ) q[0], q[1]; |
| SWAP | qc.swap(0, 1) | cirq.SWAP(q[0], q[1]) | qml.SWAP(wires=[0, 1]) | swap q[0], q[1]; | swap q[0], q[1]; |
| Toffoli | qc.ccx(0, 1, 2) | cirq.CCX(q[0], q[1], q[2]) | qml.Toffoli(wires=[0, 1, 2]) | ccx q[0], q[1], q[2]; | ccx q[0], q[1], q[2]; |
| Outcome here (q0 q1 q2) | Qiskit counts key | Cirq integer | PennyLane index |
|---|---|---|---|
| 100 | 001 | 4 | 4 |
| 011 | 110 | 3 | 3 |
| 110 | 011 | 6 | 6 |
| 001 | 100 | 1 | 1 |
Eight guides
Why convert circuits between Qiskit, Cirq and PennyLane?
6 min read
The same circuit can be written in several software kits. Why you might want to move between them, and what stays the same.
Qubit order and bit strings: the mistake that mirrors your results
7 min read
Qiskit writes qubit 0 on the right, this site and Cirq write it on the left. How to read results correctly in each.
Gates and angles across frameworks
8 min read
Names, argument order and angle conventions for the 16 gates of the Circuit Builder, in five targets.
OpenQASM 2.0 and 3.0: the common text format
7 min read
What OpenQASM is, how version 3 differs from version 2, and what the converter writes in each.
Converting a Bell circuit, line by line
7 min read
The two-qubit circuit that creates entanglement, written in all five targets and compared.
Measurement and simulation: shots, probabilities and mid-circuit readouts
7 min read
The converter moves measurements to the end and treats unmeasured circuits in a specific way. Here is what that means for results.
Checking that a conversion is correct
8 min read
How to verify that the same circuit gives the same answer in two tools, and what the lab has and has not tested.
From the Circuit Builder to real hardware
8 min read
What changes when a circuit leaves the ideal simulator: compilation, native gates, noise and queues.
Predict, then check
A circuit puts an X on qubit 0 of three qubits and measures all. What does Qiskit print, and what does this site print?
Qiskit: 001. This site: 100.
Which of the five targets write the controlled-phase gate as “cp”?
Qiskit and OpenQASM 3.0. OpenQASM 2.0 calls it cu1, PennyLane ControlledPhaseShift, and Cirq uses CZ to a power.
How does Cirq write a controlled phase of π/2?
cirq.CZ(q[0], q[1]) ** (1/2), since the exponent is the angle divided by π.
How many lines does the OpenQASM 3.0 file for the “Bell state: your first entangled pair” example have?
8 lines, including the header, the register declarations and the measurements.
Why is a circuit with no measurement exported with measurements?
So that the code produces output when it runs. The converter measures every qubit at the end.
Related on QuantumAtlas
Frequently asked questions
What does the converter do?
It writes the same circuit as code for Qiskit, Cirq, PennyLane, OpenQASM 2.0 and OpenQASM 3.0, and reads OpenQASM 2.0 or simple Qiskit code back into a circuit with exact outcome chances.
Does it run Qiskit, Cirq or PennyLane in the browser?
No. It generates text. You run the code in your own installation of the library.
Has the generated code been tested?
The OpenQASM 2.0 and Qiskit output was read back by the importer and matched the original probabilities for all 13 example circuits. The Cirq, PennyLane and OpenQASM 3.0 code was written from the tools’ documented gate names and was not executed here, so check it against the version you install.
Why do my Qiskit results look reversed?
Qiskit writes qubit 0 on the right of a bit string, while this site, Cirq and PennyLane write it on the left. Reverse the string.
Which gates are supported?
H, X, Y, Z, S, S†, T, T†, RX, RY, RZ, CNOT, CZ, controlled phase, SWAP and Toffoli, plus measurement.
How many qubits can I convert?
Up to 5 qubits and 16 columns, the same limits as the Circuit Builder.
Can I import a circuit I built in the Circuit Builder?
Yes. Paste its share link or code in the Convert tab, or use the example list.
Why does Cirq use CZ to a power for controlled phase?
Cirq expresses a controlled phase of angle θ as a CZ gate raised to the power θ/π.
Are measurements kept where I placed them?
They are moved to the end of the circuit, as in the Circuit Builder’s own simulator.
Is this a transpiler?
No. It maps gate for gate and does not optimise or fit a circuit to a device.
Sources and further reading
- A. W. Cross, L. S. Bishop, J. A. Smolin and J. M. Gambetta, “Open quantum assembly language” (2017). The original OpenQASM specification, version 2.
- A. Cross et al., “OpenQASM 3: A broader and deeper quantum assembly language” (2022). The version 3 language, with classical control and a larger standard gate library.
- Qiskit, Cirq and PennyLane documentation. Gate names, argument order and simulator options change between releases, so check the current documentation for the version you install.
- Frameworks overview on this site. A comparison of the main quantum software frameworks.
- Circuit Builder gate reference. Every gate used by the converter, with its matrix.
References were written from memory of the original works. Check the originals for exact citations.