Skip to content
UseQR
ESC

Jump to

MOVEOPEN50 places

Spec & internals

Error correction blocks and interleaving in QR codes

QR codes split data into blocks, give each its own Reed–Solomon check codewords, then interleave the codewords: first byte of block 1, first of block 2, and so on. A contiguous scratch on the symbol therefore lands one codeword deep in many blocks, instead of overwhelming a single one.

View as MarkdownPaste this page into any AI assistant. It is plain, portable Markdown.

Why blocks at all

Two reasons the bit stream is not one giant Reed–Solomon message:

  1. A hard limit. Reed–Solomon over GF(256) cannot exceed 255 codewords per message. A version 40 symbol carries 3,706 codewords (far past the ceiling), so splitting is mandatory for large versions.
  2. Decoder economics. Correction cost grows steeply with block length and error count. Many small blocks, each with its own modest budget, kept 1990s scanner hardware (and keeps today's phone firmware) fast.

The block structure (how many blocks, how many data and check codewords in each) is fixed by a table in ISO/IEC 18004 for every version and error-correction level combination. Nothing about it is chosen by the generator.

A concrete structure: version 5-Q

Block Data codewords EC codewords Total
1 15 18 33
2 15 18 33
3 16 18 34
4 16 18 34
Total 62 72 134

Note the mixed sizes: two blocks of 15 data codewords, two of 16. The standard uses this two-group trick throughout to make the totals divide cleanly. Each block independently gets its own 18 check codewords, computed as described in Reed–Solomon error correction.

The interleave

The codewords are then woven, not concatenated. Data first, round-robin:

D1[0] D2[0] D3[0] D4[0]  D1[1] D2[1] D3[1] D4[1]  …

First codeword of every block, then second of every block, and so on; blocks with an extra codeword contribute it at the end. Then all check codewords, interleaved the same way. The result is one final sequence that goes to zig-zag placement in the symbol.

What this buys

Physical damage is almost never uniformly scattered. It is a scratch, a fold, a coffee ring, a strip of glare: a burst of consecutive ruined modules. Without interleaving, a burst of 20 codewords would annihilate one block (budget: 9 unknown errors) while its neighbours sat untouched. With interleaving, those same 20 consecutive codewords land 5 deep in each of the four blocks, every block corrects its share easily.

This is why a thin scratch clean across a printed QR code is so often survivable, and why damage-tolerance percentages hold up in practice against real-world wear rather than only against idealised random noise. The symbol's correction capacity is a per-block resource; interleaving is what makes the blocks share load.

The design has one sharp edge worth knowing: the guarantee is statistical, not absolute. A burst aligned just wrongly (or damage concentrated where one block's codewords happen to cluster after placement) can still sink a single block, and one failed block fails the whole decode. Robustness engineering for print therefore still starts with adequate module size and margin, with error correction as the safety net rather than the plan. When a code will live somewhere hostile, verify a worn sample actually decodes, not just the master file.

FAQ

Why are QR codes split into blocks?

Reed–Solomon over GF(256) supports at most 255 codewords per message, so large symbols must split. Smaller blocks also keep error-correction computation cheap, which mattered on the scanner hardware QR codes were designed for.

What is interleaving in a QR code?

The final codeword sequence takes one codeword from each block in turn (first of block 1, first of block 2, and so on), rather than writing blocks one after another. Consecutive physical damage is therefore shared across all blocks.

Why does a scratch across a QR code often not break it?

Because interleaving spreads any contiguous run of damaged codewords thinly across every block, and each block repairs its small share. The same total damage concentrated in one block would exceed its budget and fail the decode.

Who decides the block structure?

The standard. ISO/IEC 18004 fixes the number of blocks and the data and check codeword counts for every version and error-correction level. Generators look the structure up; they never choose it.

Try it: free, no signup