Explainers

What a QR code actually stores

A short, practical guide to what bytes a QR code contains, how ISO/IEC 18004 arranges modes, segments and error‑correction, and why payloads often add wrappers like HC1/Base45.

Originally published:

Close-up photograph of a printed museum panel showing a QR code and nearby instructional text for retrieving a soldier's information. (file photo)
File photo: close-up of the QR-code panel used by the In Flanders Fields Museum (Poperinge). Credit: J. Nic. K. Y., licensed CC BY 4.0. Photo: J. Nic. K. Y.  · CC BY 4.0.

Quick answer: what a scan actually gives you

When you scan a QR code you normally get a decoded string or a raw byte sequence — not a set of labelled fields. The QR encoder packs bits into the modules; the reader returns the interpreted bytes or ASCII string and then the scanning app decides how to parse it. This is why many QR workflows include extra decoding steps in software after the scan. [1], [4]

How data is arranged inside a QR code

Under ISO/IEC 18004 a QR payload is built from one or more segments. Each segment starts with a mode indicator (numeric, alphanumeric, byte, Kanji, etc.) and a character‑count field that tells a decoder how many characters that segment carries, letting encoders mix modes to be efficient. Practical libraries follow this rule and choose modes to minimize code size. [1]

Because the QR bitstream is segment‑based, the same visual code can contain a short numeric segment followed by a byte segment — the reader concatenates decoded segments into the final returned string or byte array. [1]

Version and error correction: how much fits and how robust it is

A QR’s capacity depends on its version (physical size) and the chosen Reed–Solomon error‑correction level. Higher versions and lower correction let you store more data; higher correction stores fewer user bytes but tolerates more damage to the printed code. Encoder tools expose these trade‑offs when they produce the final bitstream. [1]

Why many QR payloads look like gibberish at first (the EU DCC example)

Application formats often wrap their structured data into a single ASCII string before QR encoding. The EU Digital COVID Certificate is a concrete example: the certificate pipeline prefixes the final string with a context marker, compresses the payload, and then encodes it into an ASCII payload that the QR encodes as a byte segment. The official implementing decision and technical specification document this HC1: → Base45 → zlib/Deflate → COSE/CWT pipeline. [3], [4]

So when a scanner shows an HC1:… string, that is the decoded text the QR held; an additional Base45 decode, zlib inflate and COSE/CWT parsing step is needed to reach the underlying health claims. The QR itself only carried the final ASCII bytes. [3], [4]

Custom binary wrappers and QRscript

Beyond standard app wrappers, researchers have proposed binary wrapper formats to put structured records inside QR payloads. The QRscript specification describes a compact binary header and field layout that an encoder can place inside the ISO payload, so a single QR can hold typed fields rather than plain text. That makes automated parsing easier for compliant readers but still requires software that understands the wrapper. [2]

Because such wrappers are just bytes inside the QR’s byte‑mode segments, ordinary scanners will return the raw bytes or a byte‑to‑text rendering; only a wrapper‑aware parser will extract the structured contents. [2]

Practical takeaways: what to expect and why it matters

If you want the actual data from a QR, expect a single decoded string or a byte blob; whether that is human‑readable depends on what the issuer wrapped in it. Popular formats may use clear prefixes (like HC1:) to signal how to decode further, while some payloads use compression or binary wrappers that need extra parsing. [1], [3], [4]

For everyday users: a scan that looks like a URL is usually ready to open, but anything that looks like a short code or a long opaque string often needs additional decoding steps by an app. For implementers: remember encoders mix modes and use character‑count fields, so you must follow ISO/IEC 18004 parsing rules to reconstruct segments reliably. [1], [3], [4], [2]

Sources & further reading

  1. segno/docs/qrcode-modes.rst at master · heuer/segno · GitHub ↗github.com · Primary source
  2. QRscript specification (arXiv preprint) ↗arxiv.org · Primary source
  3. Implementing decision - 2021/1073 - EN - EUR-Lex ↗europa.eu · Primary source
  4. eHealth Network — Digital COVID Certificate v4 (technical specification) ↗europa.eu · Primary source
Email

What do you think?

Join the conversation with your Ali Pro account. Keep it kind, stay on topic, and leave personal details out.

Keep exploring

All stories ↗
Explainers

Why bread rises — 5 practical takeaways

Five short, kitchen-friendly science points that explain how fermentation, gluten, enzymes, hydration and leavening control dough rise and crumb.

3 min read

No inputs, files, account or visitor identifiers are included. Untick to stop. This browser remembers your choice.