QR Codes · 8 min read · Updated June 10, 2026
How Do QR Codes Work? The Complete Technical Guide
Point a phone camera at a QR code and a link opens in about a second. The mechanics behind that second are genuinely clever: a grid of dark and light squares that encodes data, tells the camera where it is from any angle, and survives scratches, smudges, and bad lighting thanks to the same math that keeps a scratched CD playable.
This guide explains how QR codes work from the pattern up: what the squares actually mean, how error correction rebuilds damaged data, why some codes can be re-pointed after printing while others are frozen forever, and the practical sizing and contrast rules that decide whether your printed code scans on the first try.
What a QR code actually encodes
A QR code (Quick Response code) is a two-dimensional barcode that stores data as a grid of dark and light squares called modules. Each module represents one bit. The format was invented in 1994 by Masahiro Hara at Denso Wave, a Toyota subsidiary, to track automotive parts faster than one-dimensional barcodes allowed, and it is now an open standard defined in ISO/IEC 18004.
Before the data becomes squares, it is compressed using one of four encoding modes. The mode matters because it determines how much content fits in a code of a given size:
- Numeric — digits 0–9 only, packed three digits into 10 bits. The densest mode by far.
- Alphanumeric — a 45-character set (digits, uppercase A–Z, space, and a few symbols), packed two characters into 11 bits.
- Byte — 8 bits per character, used for anything else. Most URLs end up in byte mode because they contain lowercase letters.
- Kanji — Shift JIS double-byte characters packed into 13 bits each.
The payload itself is just text. What makes a QR code open a website, join a network, or save an event is a convention the scanner recognizes: a URL triggers the browser, a WIFI: string like the one a WiFi QR code produces prompts the phone to join a network, and an iCalendar block from an event QR code offers to save a calendar entry.
The anatomy of a QR code
Look closely at any QR code and you will see structure, not noise. Several fixed patterns exist purely so a camera can find and read the grid:
- Finder patterns — the three large squares in the top-left, top-right, and bottom-left corners. Each is a 7×7 module bullseye whose dark-light ratio reads 1:1:3:1:1 along any line through its center, in any direction. That property lets a scanner locate the code at any rotation.
- Alignment patterns — smaller 5×5 squares that appear from version 2 onward (more of them in larger codes). They let the decoder correct for perspective distortion and surface curvature.
- Timing patterns — a line of alternating dark and light modules running between the finder patterns along row 6 and column 6. They tell the decoder exactly how many modules the grid contains and where each row and column sits.
- Quiet zone — the empty margin around the code, four modules wide on every side per the spec. Without it, the scanner cannot separate the code from its surroundings.
- Format information — 15 bits near the finder patterns that record the error correction level and the mask pattern, stored twice for redundancy.
- Data modules — everything else. Data and error-correction codewords fill the remaining area in a zigzag path starting from the bottom-right corner.
One last detail: before output, the data region is XORed with one of eight mask patterns. The encoder scores all eight and picks the one that best avoids large blank areas and accidental shapes that resemble finder patterns, which keeps the code reliably scannable.
Error correction: why damaged codes still scan
QR codes use Reed-Solomon error correction, the same family of codes that lets CDs and DVDs play through scratches. The encoder splits the payload into codewords, computes redundant correction codewords from them, and interleaves both through the grid. When part of the symbol is dirty, torn, or covered, the decoder uses the redundancy to reconstruct the missing codewords exactly.
You choose how much redundancy to spend. There are four levels:
| Level | Recoverable damage | When to use it |
|---|---|---|
| L | ~7% of codewords | Clean digital display where every module stays crisp |
| M | ~15% of codewords | The sensible default for most uses |
| Q | ~25% of codewords | Print that gets handled, weathered, or laminated |
| H | ~30% of codewords | Codes with a logo overlay or harsh environments |
The trade-off is density: the same URL at level H needs roughly twice the data area it needs at level L, which means smaller modules at the same print size. Logo-in-the-middle QR codes work by deliberately destroying the modules under the logo and letting level H correction rebuild them — which is also why an oversized logo on a level L code fails.
Static vs. dynamic QR codes
A static QR code encodes the final content directly. The destination URL, WiFi password, or event details are baked into the pattern itself. It needs no service to keep working, but it can never change: a typo, a moved page, or a new campaign URL means reprinting everything the code appears on.
A dynamic QR code encodes a short redirect URL instead. The pattern stays identical forever; only the destination behind the redirect changes. That single indirection adds three things static codes cannot offer: you can re-point the code after it is printed, you can count and analyze scans (each scan is a click on the short link), and the shorter URL produces a lower-version, less dense code that scans more reliably at small sizes.
This is where a link shortener does the work. Every link you shorten with ReSlug comes with a QR code automatically, and because the code points at the short link, you can edit the destination later and watch scans appear in the link's analytics with geo and device breakdowns — see the full feature list for what each plan includes. If you run the same offer across several posters, give each placement its own short link with campaign parameters so you can compare locations; what are UTM parameters covers how to tag those destinations properly.
QR versions and data capacity
QR codes come in 40 sizes called versions. Version 1 is a 21×21 module grid, and each version adds 4 modules per side, up to version 40 at 177×177. The encoder picks the smallest version that fits your content at the chosen error correction level. Capacity at level L looks like this:
| Version | Modules | Numeric | Alphanumeric | Byte |
|---|---|---|---|---|
| 1 | 21×21 | 41 | 25 | 17 |
| 5 | 37×37 | 255 | 154 | 106 |
| 10 | 57×57 | 652 | 395 | 271 |
| 40 | 177×177 | 7,089 | 4,296 | 2,953 |
In practice you want the lowest version you can get, because fewer modules means each module prints larger and scans from farther away. A 30-character short URL lands around version 2 or 3; a 200-character URL with tracking parameters can push past version 10 and become fragile at business-card size. Shortening the URL before generating the code is the single easiest density win.
How your phone scans a QR code
Modern camera apps scan continuously without a dedicated mode. Each frame goes through the same pipeline:
- The image is converted to grayscale and thresholded into pure black and white.
- The decoder sweeps the image for the 1:1:3:1:1 finder-pattern ratio to locate the three corner squares, which also reveals the code's rotation.
- Using the finder and alignment patterns, it computes a perspective transform that maps the photographed shape back to a flat, square grid.
- The timing patterns give the module count, and each module is sampled to a bit.
- The mask is removed, the format information is read, and Reed-Solomon correction repairs any misread codewords.
- The decoded text is handed to the operating system, which shows a preview or routes it to the right handler — browser, WiFi settings, calendar, and so on.
The whole pipeline runs in milliseconds per frame. It also works on a saved picture, not just a live camera — a QR code reader applies the same steps to a screenshot or photo and shows you the decoded content before you act on it.
Sizing, contrast, and print rules
Most real-world scan failures are physical, not digital. A few rules cover nearly all of them:
- Size for distance. A code should be at least one tenth of the expected scanning distance: 10 cm wide for a poster scanned from a meter away, with a practical floor of about 2×2 cm on anything handheld.
- Keep the quiet zone. Leave a clear margin of at least four module widths on every side. Decorative borders that crowd the code are a top cause of failed scans.
- Dark on light. Scanners expect dark modules on a light background. Inverted (light-on-dark) codes fail on many readers; if your design is dark, put the code on a light panel.
- Contrast matters more than color. Brand colors are fine if the foreground is clearly darker than the background. A QR code generator with a contrast warning catches the risky combinations before you print.
- Export at print resolution. Generate at 1000 px or as vector for posters; upscaling a small PNG blurs module edges and confuses thresholding.
- Avoid gloss and curves. Glare from lamination and distortion from bottles or sleeves both break module sampling; matte finishes and flat placements scan best.
Common reasons QR codes fail
When a code will not scan, the cause is almost always one of these:
- Too much data: a long URL forced a high version, and the modules are too small at the printed size.
- Missing or cramped quiet zone, so the scanner never isolates the symbol.
- Low contrast, an inverted color scheme, or a busy background bleeding into the grid.
- A logo or sticker covering more of the code than the error correction level can recover, or covering a finder pattern.
- Blur, glare, or low resolution — common with codes re-photographed from screens.
- The code scans fine but the destination is dead: the page moved, the campaign ended, or a static code points at a URL that no longer resolves. A dynamic code behind a short link is the only fix that does not involve reprinting.
If a printed code misbehaves, decode it from a photo first to confirm what it actually contains, then test the destination URL separately. The two failure classes — unreadable pattern and broken destination — need different fixes, and knowing which one you have saves a reprint.
Frequently asked questions
Do QR codes expire?
The pattern itself never expires; it is just encoded data. A static QR code works for as long as the content inside it stays valid, such as a URL that still resolves. A dynamic QR code depends on the redirect service behind it staying active, which is why it matters to use a provider you trust for codes that live in print.
Can a QR code be hacked?
A printed QR code cannot be altered remotely; the data is fixed in the pattern. The real risks are physical and social: attackers stick a malicious code over a legitimate one, or distribute codes that lead to phishing pages, a tactic known as quishing. Modern phones show the destination URL before opening it, so check the domain, and decode suspicious codes with a reader before visiting the link.
How much data can a QR code hold?
At the largest size, version 40 with error correction level L, a QR code holds up to 7,089 numeric digits, 4,296 alphanumeric characters, or 2,953 bytes. Practical codes should carry far less, because high-version codes are dense and hard to scan from print. A short URL of 30 to 40 characters keeps the code small and reliable.
Why does my QR code scan slowly or not at all?
The usual causes are a code that is too dense for its printed size, low contrast or inverted colors, a missing quiet zone around the code, glare or blur, or a logo covering more than the error correction can repair. Shorten the encoded URL, print larger, keep dark modules on a light background, and leave a clear margin on all sides.
Related tools
Keep reading
What Are UTM Parameters? A Practical Guide for Marketers
Learn what UTM parameters are, how utm_source, utm_medium, and utm_campaign work, naming rules that keep reports clean, and when not to tag a link.
Creators · 7 min readLink in Bio Ideas: What to Put on Your Page (and Why)
Practical link in bio ideas for creators, small businesses, artists, and freelancers — plus layout rules, click tracking, and mistakes to avoid.