QR Code: Versions, Masking, Reed–Solomon & Module Geometry Guide
A deep QR Code reference covering versions 1–40, finder and alignment patterns, encoding modes, data placement, masking, format/version information, Reed–Solomon error correction, quiet zones, sizing, and print QA.
1. QR Code Matrix Model
QR Code Model 2 is built from square modules arranged in a matrix. Version 1 is 21×21 modules; each higher version adds four modules per side until Version 40 reaches 177×177.
To create a QR Code, use our free online barcode generator and download the result as PNG, JPG, or SVG.
2. Functional Patterns vs Data Modules
| Pattern | Purpose |
|---|---|
| Finder patterns | Locate and orient the symbol. |
| Separators | Isolate finder patterns. |
| Timing patterns | Reconstruct module grid. |
| Alignment patterns | Compensate for distortion on larger versions. |
| Format information | Carries error-correction level and mask. |
| Version information | Present for higher versions. |
| Data/ECC modules | Carry encoded payload and recovery codewords. |
3. Encoding Modes
| Mode | Best Fit | Density Note |
|---|---|---|
| Numeric | Digits only | Most efficient for decimal data. |
| Alphanumeric | Restricted character set | More efficient than byte for supported text. |
| Byte | General data / URLs | Flexible. |
| Kanji | Supported Japanese characters | Specialized compact mode. |
4. Version Selection
Version is determined by the encoded bitstream, character mode and selected error-correction level—not simply the visible character count. Mixed-mode optimization can reduce the required version.
Engineering goal
Use the smallest version that safely fits the payload at the required error-correction level; unnecessary density makes printing/scanning harder.
5. Reed–Solomon Error Correction
QR Code adds Reed–Solomon error-correction codewords. Levels L, M, Q and H provide increasing redundancy; DENSO WAVE describes approximate restoration rates of about 7%, 15%, 25% and 30% of codewords respectively.
| Level | Approx. Recovery | Trade-Off |
|---|---|---|
| L | ~7% | More capacity |
| M | ~15% | Balanced |
| Q | ~25% | More redundancy |
| H | ~30% | Highest standard redundancy |
6. Data Placement and Masking
After the bitstream and error-correction codewords are prepared, modules are placed in the data region. A mask pattern is applied to avoid visually problematic structures such as large same-color regions or patterns that could confuse detection. The chosen mask is recorded in format information.
7. Quiet Zone
QR Code requires a clear margin four modules wide on all sides. That margin is part of the required symbol area and must remain free of text, borders and artwork.
Sizing rule
Total printed width = (matrix modules + 8 quiet-zone modules) × physical module size.
8. Physical Size Example
A Version 3 QR Code is 29×29 modules. At 0.254 mm per module, the matrix body is 7.366 mm. Adding four modules of quiet zone on each side gives 37 modules total, or 9.398 mm overall.
9. Print Resolution and Module Size
| Variable | Failure | Response |
|---|---|---|
| Too few printer dots/module | Ragged/merged modules | Increase module size. |
| Non-integer raster scaling | Uneven module widths | Render at exact pixel multiples. |
| Glossy material | Exposure/glare | Test final substrate. |
| Logo overlay | Lost modules | Keep small and verify final code. |
10. Scanner Decode Pipeline
11. Error Correction Is Not a Design License
Error correction is intended to improve resilience, not to justify covering finder patterns, removing quiet zones or printing modules below reliable dimensions. Damage location and codeword distribution matter.
12. Production Checklist
Validate payload, mode/version choice, error-correction level, four-module quiet zone, square scaling, final module size, contrast, substrate and scans on representative phones/readers.
13. Format Information and BCH Protection
Format information is itself protected so the decoder can recover the error-correction level and selected mask even when some format modules are damaged. This metadata is placed redundantly in the symbol, helping orientation and decoding under imperfect conditions.
14. Version Information in Larger Symbols
Version information is explicitly encoded in QR versions 7 and above. Lower versions can be inferred from matrix dimensions alone, while larger symbols carry protected version bits so the decoder can confirm the intended structure.
15. Structured Data vs URL Redirection
For many web use cases, encoding a short stable HTTPS URL is preferable to embedding a large JSON or text payload. A short URL reduces matrix density and allows the server to change destination content without reprinting the symbol. The trade-off is dependence on the redirect/service remaining available.
16. Camera Resolution and Scan Distance
As scan distance increases, each module occupies fewer camera pixels. A symbol that works at 15 cm may fail at 1 metre even under identical lighting. Physical module size should therefore be chosen with both print resolution and expected camera distance in mind.
17. Mode Switching Inside One QR Code
A QR encoder can switch encoding modes within one symbol. For example, a long numeric prefix can use Numeric mode while the remainder uses Byte mode. This can reduce the total bitstream and sometimes avoid moving to a larger QR version. Production libraries should handle segmentation automatically where possible instead of forcing the entire payload into the least efficient mode.
18. Mask Evaluation and Penalty Rules
The eight QR mask candidates are evaluated using penalty rules that discourage long runs of identical modules, large monochrome blocks, finder-like patterns in the data area and excessive imbalance between dark and light modules. The encoder chooses the mask with the lowest penalty. This step is essential because the same payload can produce visibly different matrices depending on the selected mask.
Related Guides
Continue with closely related technical references.