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.

Or paste a Circuit Builder share link or code
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.
Generated text. See the note below the lab on what has been tested.

The circuit

q0: |0⟩──H──M──

Exact outcome chances, in this site’s order (qubit 0 on the left)

|0⟩50.0%
|1⟩50.0%

A five-minute path

  1. Convert tab: choose the Bell state example. Read the Qiskit code, then switch to Cirq and PennyLane.
  2. Choose an example with a rotation gate. See how each tool writes the angle.
  3. Bit order tab: type 100 and see why Qiskit shows 001.
  4. Paste code tab: edit the sample OpenQASM and watch the circuit and probabilities change.
  5. Click “Open in Circuit Builder” to continue editing the pasted circuit.
  6. 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.

Every gate of the Circuit Builder in every target, with θ standing for an angle in radians.
GateQiskitCirqPennyLaneOpenQASM 2.0OpenQASM 3.0
Hadamardqc.h(0)cirq.H(q[0])qml.Hadamard(wires=0)h q[0];h q[0];
Pauli Xqc.x(0)cirq.X(q[0])qml.PauliX(wires=0)x q[0];x q[0];
Pauli Yqc.y(0)cirq.Y(q[0])qml.PauliY(wires=0)y q[0];y q[0];
Pauli Zqc.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 daggerqc.sdg(0)cirq.S(q[0]) ** -1qml.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 daggerqc.tdg(0)cirq.T(q[0]) ** -1qml.adjoint(qml.T)(wires=0)tdg q[0];tdg q[0];
Rotation about Xqc.rx(θ, 0)cirq.rx(θ)(q[0])qml.RX(θ, wires=0)rx(θ) q[0];rx(θ) q[0];
Rotation about Yqc.ry(θ, 0)cirq.ry(θ)(q[0])qml.RY(θ, wires=0)ry(θ) q[0];ry(θ) q[0];
Rotation about Zqc.rz(θ, 0)cirq.rz(θ)(q[0])qml.RZ(θ, wires=0)rz(θ) q[0];rz(θ) q[0];
CNOTqc.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 Zqc.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 phaseqc.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];
SWAPqc.swap(0, 1)cirq.SWAP(q[0], q[1])qml.SWAP(wires=[0, 1])swap q[0], q[1];swap q[0], q[1];
Toffoliqc.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];
The same outcome in each tool. This site lists qubit 0 first.
Outcome here (q0 q1 q2)Qiskit counts keyCirq integerPennyLane index
10000144
01111033
11001166
00110011

Eight guides

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.