← Back to QRForged

How QR Codes Work: The Technology Behind the Square

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.

Anatomy of a QR Code

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.

Finder Patterns (The Three Big Squares)

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.

Alignment Patterns

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.

Timing Patterns

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.

Format Information

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.

Data and Error Correction Area

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.

Data Encoding: Four Modes

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.

ModeCharactersBits per Character
Numeric0–93.33
Alphanumeric0–9, A–Z, space, $%*+-./:=5.5
ByteAny (ISO 8859-1 / UTF-8)8
KanjiJapanese characters13

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.

Versions and Capacity

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.

The Magic: Error Correction

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:

LevelRecovery CapacityBest For
L (Low)~7% damage recoveryClean environments, maximum data capacity
M (Medium)~15% damage recoveryGeneral purpose (most common)
Q (Quartile)~25% damage recoveryIndustrial use, moderate wear expected
H (High)~30% damage recoveryHarsh 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.

How Reed-Solomon Works (Simplified)

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.

Masking: Preventing Scanner Confusion

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.

The Scanning Process

When your phone camera reads a QR code, it runs through all of this — every step below — in a fraction of a second:

  1. Detection — Find the three finder patterns in the image; determine position, size, and rotation
  2. Sampling — Use timing and alignment patterns to create a precise grid of module positions
  3. Format decoding — Read the error correction level and mask pattern
  4. Unmasking — Apply the inverse of the mask pattern to reveal the raw data
  5. Error correction — Use Reed-Solomon to detect and fix any corrupted modules
  6. Data decoding — Interpret the binary data according to its encoding mode(s)
  7. Action — Open the URL, display the text, connect to Wi-Fi, etc.

Why QR Codes Look "Random"

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.

The Quiet Zone

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 →

More Articles

The History of QR Codes QR Codes in Business & Marketing QR Code Design Best Practices QR Code Security & Safety Guide QR Codes vs Barcodes: What's the Difference?