OpenQASM 2.0 and 3.0: the common text format

What OpenQASM is, how version 3 differs from version 2, and what the converter writes in each.

7 min read · reviewed December 2026

What it is

OpenQASM is a plain-text language for describing circuits. A file declares qubits and classical bits, lists gates one per line, and ends with measurements. Because it is only text, many tools can read and write it, which makes it a common meeting point between frameworks.

Version 2.0

  • Header OPENQASM 2.0; and an include of qelib1.inc, which defines the standard gates.
  • qreg q[3]; and creg c[3]; declare registers.
  • Gates look like h q[0]; and cx q[0], q[1];
  • Measurement is written measure q[0] -> c[0];
  • The controlled-phase gate is called cu1.

Version 3.0

  • Header OPENQASM 3.0; and include stdgates.inc.
  • Declarations are qubit[3] q; and bit[3] c;
  • Measurement is written c[0] = measure q[0];
  • The controlled-phase gate is called cp.
  • The language adds classical control flow and timing, which the converter does not use.

What the importer reads

The Paste code tab reads OpenQASM 2.0 with these gates: h, x, y, z, s, sdg, t, tdg, rx, ry, rz, cx, cz, cu1 or cp, swap, ccx, plus measure and barrier. It does not read user-defined gates, loops, conditionals or version 3. It tells you which line it cannot read.

Angles may be written as numbers, pi, and the operations + − × ÷ with brackets, for example 3*pi/4.

Try it

Questions

Which version should I use?

Use the one your target tool reads. Version 2.0 is read by the widest range of older tools, and version 3.0 is the current language.

Can I paste QASM from IBM Quantum or another site?

If it uses only the gates above and at most 5 qubits, yes. Larger circuits are outside the lab’s limits.

Are barriers kept?

They are ignored on import. The Qiskit export of the Circuit Builder inserts its own.

Read next

Sources and further reading

Check the original sources for exact citations.