qrcodo
Explainer

How a QR code actually works

A QR code looks like noise, but every module has a job. Here’s what the generator on our home page does in the few milliseconds after you type a character.

The anatomy

The code below says qrcodo.com. It’s a version 1 symbol — the smallest kind, 21×21 modules. Coloured overlays mark the fixed “function patterns”; everything else is your data plus error correction.

finder timing format info data + ECC
A real, scannable version 1-M code with its function patterns highlighted.

Finder patterns: “I’m a QR code, and this way is up”

The three big squares in the corners are finder patterns. Cut straight through one in any direction and you get dark–light–dark–light–dark in a 1:1:3:1:1 ratio. That ratio stays the same no matter how far away, tilted or rotated the code is, so a camera can spot it quickly in a messy image. Three corners are enough to work out orientation; the missing fourth tells the reader which way is up.

11311
Any line through the centre crosses modules in a 1:1:3:1:1 ratio.

Each finder is wrapped in a one-module white separator. Between them run two timing patterns — a row and a column of alternating dark and light modules — which let the reader measure the module grid even when the print is slightly warped. From version 2 up, smaller alignment patterns (5×5 bullseyes) are sprinkled across the symbol to correct for perspective and curved surfaces like coffee cups.

Error correction: why a smudged code still scans

Your text is converted to bytes (we use UTF-8, so emoji and accents work), prefixed with a mode indicator and length, then padded to fill the symbol’s data capacity. Then comes the clever part: Reed–Solomon error correction. The data bytes are treated as the coefficients of a polynomial over a 256-element finite field and divided by a fixed generator polynomial; the remainder becomes extra “ECC” codewords appended to the data.

16 data codewords10 ECC
A version 1-M code carries 16 data codewords and 10 error correction codewords.

With n ECC codewords a reader can repair up to n/2 damaged codewords — without knowing in advance which ones are wrong. You choose how much room to spend on this:

LevelRecovers roughlyGood for
L7% of codewordsScreens, clean digital use
M15%Most printing (our default)
Q25%Menus, stickers, packaging
H30%Outdoor signs, codes with a logo on top

Bigger symbols split the data into several blocks, each with its own ECC, and then interleave them byte by byte. A coffee ring that wipes out one area damages a little of every block instead of all of one block — which keeps each block within its repair budget.

Masks: keeping the pattern readable

Raw data can produce unlucky shapes: big solid blobs, long stripes, or accidental look-alikes of a finder pattern that confuse scanners. So the encoder flips (XORs) every data module according to one of eight mask patterns:

mask 0mask 1mask 2mask 3mask 4mask 5mask 6mask 7
Where a mask is coloured, data modules get inverted. r = row, c = column.

The encoder tries all eight and scores each result with four penalty rules from the standard: runs of five or more same-coloured modules, 2×2 solid blocks, finder-like 1:1:3:1:1 sequences, and an overall dark/light imbalance. The mask with the lowest score wins, and its number is written into the format information — 15 bits, protected by a BCH code and stored twice, next to the finders — along with the error correction level. That’s the number you see as “mask” under the preview on our generator.

Versions: how big is the code?

There are 40 versions. Each step adds 4 modules per side, from 21×21 up to 177×177. Versions 7 and above also carry an 18-bit version information block near two of the finders. qrcodo always picks the smallest version that fits your content at the level you chose. Capacity in bytes:

VersionModulesLMQH
121×211714117
225×2532262014
329×2953423224
433×3378624634
537×37106846044
745×451541228664
1057×57271213151119
1577×77520412292220
25117×1171,273997715535
40177×1772,9532,3311,6631,273

Rule of thumb: every time you halve the length of your link, the modules get noticeably bigger and the code scans from further away. If you’re printing, shorten first.

Placing the bits

Finally the codewords are laid into the grid in a zig-zag: two columns at a time, starting bottom-right, snaking up then down, skipping anything that belongs to a function pattern. Readers do the whole thing in reverse — find the finders, sample the grid, read the format bits, unmask, un-zig-zag, repair with Reed–Solomon — usually in a fraction of a second.

QR Code is a registered trademark of DENSO WAVE INCORPORATED. The format is specified in ISO/IEC 18004.