Published April 6, 2026 · 10 min read
You point your phone at a grid of black and white squares and — instantly — a website opens. No typing, no searching. It almost feels like a magic trick. But there's real engineering underneath: mathematics, pattern recognition, and error-correcting algorithms that were originally designed for space probes. That little square is doing a lot of work.
A QR code isn't just noise. Every region of that grid has a job, and they all have to cooperate for a scan to succeed. Here's what's actually going on inside.
Those three large squares in the corners — top-left, top-right, bottom-left — are called finder patterns, and they exist for one reason: orientation detection. They're how a scanner knows it's looking at a QR code and not random noise.
When a camera spots all three, it can figure out:
Why exactly three and not four? Three points define a plane — that's enough to correct for tilt and rotation. The missing fourth corner is actually the clue that tells the scanner which way is up.
Larger QR codes (version 2 and up) contain smaller squares scattered through the data area. These are alignment patterns, and they exist specifically to handle distortion. Think about scanning a QR code printed on a curved bottle or a crumpled receipt — alignment patterns give the scanner fixed reference points to straighten everything out.
Running between the finder patterns, both horizontally and vertically, are alternating black and white modules. Boring to look at, but important: they let the scanner calculate the exact size and count of each module, even when the image is slightly warped or off-angle.
There's a strip of data tucked right next to the finder patterns that the scanner reads before anything else. It carries two pieces of critical metadata: the error correction level and the mask pattern. Without those, the scanner can't interpret the rest of the code.
Everything that's left — the bulk of the code, all those seemingly random dots — is the actual payload: encoded data plus the error correction codewords that protect it.
QR codes don't treat all content the same way. Instead of forcing everything through one encoding scheme, they support four different modes — each tuned for a specific type of data. The encoder picks whichever is most efficient.
| Mode | Characters | Bits per Character |
|---|---|---|
| Numeric | 0–9 | 3.33 |
| Alphanumeric | 0–9, A–Z, space, $%*+-./:= | 5.5 |
| Byte | Any (ISO 8859-1 / UTF-8) | 8 |
| Kanji | Japanese characters | 13 |
So a QR code storing a phone number — all digits — uses Numeric mode and squeezes in far more characters than an identically-sized code storing a URL, which needs Byte mode. The encoder handles mode selection automatically, and it can even switch modes mid-stream if the content is mixed.
QR codes come in 40 sizes, referred to as versions. Version 1 starts at a 21×21 module grid. Each version up adds 4 modules per side, so Version 40 — the largest — is a sprawling 177×177 grid.
Maximum capacity (Version 40, lowest error correction): 7,089 numeric characters, 4,296 alphanumeric characters, or 2,953 bytes of binary data. That's enough for a short essay.
In practice, most QR codes you actually encounter land somewhere between Version 2 (25×25) and Version 10 (57×57) — big enough to hold a URL or a contact card, small enough to scan without fuss.
Honestly, this is the part that still impresses me most. Every QR code bakes in redundant data using Reed-Solomon error correction — the same family of algorithms that CDs, DVDs, satellite communications, and deep-space probes rely on. That's not a small thing to have inside a printable square.
There are four error correction levels:
| Level | Recovery Capacity | Best For |
|---|---|---|
| L (Low) | ~7% damage recovery | Clean environments, maximum data capacity |
| M (Medium) | ~15% damage recovery | General purpose (most common) |
| Q (Quartile) | ~25% damage recovery | Industrial use, moderate wear expected |
| H (High) | ~30% damage recovery | Harsh environments, logo overlays |
This is exactly why you can slap a logo in the center of a QR code and it still scans — the error correction fills in the missing data. It's also why a coffee-stained QR code on a crumpled receipt will sometimes still work, which feels like it shouldn't be possible.
The Reed-Solomon algorithm treats your data as a polynomial — a mathematical expression — then generates a set of additional "check" values from it. When the scanner reads the code, those check values let it detect and fix corrupted modules. Think of it like sending a message with enough built-in hints that the recipient can reconstruct what you said even if a chunk of it arrives garbled.
Once the data is encoded into the grid, there's one more step before the code is done: masking. Raw data has a habit of producing large solid areas of a single color, or patterns that look suspiciously like finder patterns. Both of those things confuse scanners badly.
The QR specification defines 8 mask patterns — each one a simple mathematical rule for flipping certain modules. The encoder runs through all 8, scores each for scan-friendliness (penalizing solid patches, fake finder patterns, and similar trouble spots), and picks the winner. The chosen mask's ID gets written into the format information strip so the scanner can reverse it on the other end.
When your phone camera reads a QR code, it runs through all of this — every step below — in a fraction of a second:
The data area isn't laid out in tidy rows or columns. Data snakes through the grid in a zigzag path — two-column strips that alternate up and down, moving from right to left. Layer masking on top of that layout and you get something that looks completely chaotic. It isn't. Every single module is placed exactly where the algorithm says it should be.
That white border around a QR code looks like padding, but it's actually a required functional element. The "quiet zone" — minimum 4 modules wide — is what lets the scanner tell where the code ends and the background begins. Crop it too tightly and the scan will fail. This is, genuinely, one of the most common reasons QR codes stop working in the real world.
See the technology in action — create a QR code in seconds
Try the QR Generator →