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 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.
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.
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:
| Level | Recovers roughly | Good for |
|---|---|---|
| L | 7% of codewords | Screens, clean digital use |
| M | 15% | Most printing (our default) |
| Q | 25% | Menus, stickers, packaging |
| H | 30% | 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:
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:
| Version | Modules | L | M | Q | H |
|---|---|---|---|---|---|
| 1 | 21×21 | 17 | 14 | 11 | 7 |
| 2 | 25×25 | 32 | 26 | 20 | 14 |
| 3 | 29×29 | 53 | 42 | 32 | 24 |
| 4 | 33×33 | 78 | 62 | 46 | 34 |
| 5 | 37×37 | 106 | 84 | 60 | 44 |
| 7 | 45×45 | 154 | 122 | 86 | 64 |
| 10 | 57×57 | 271 | 213 | 151 | 119 |
| 15 | 77×77 | 520 | 412 | 292 | 220 |
| 25 | 117×117 | 1,273 | 997 | 715 | 535 |
| 40 | 177×177 | 2,953 | 2,331 | 1,663 | 1,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.