QR code · 8
QR mask pattern
One of eight XOR patterns applied to data modules to avoid large blank or blocky areas.
Key facts
| Patterns | 8 |
|---|---|
| Applied to | Data and error-correction modules |
| Not applied to | Finder, timing, alignment and format areas |
| Selection | Lowest penalty score |
| Recorded in | Format information (3 bits) |
Why masks exist
Raw data can produce long runs of dark or light modules, or large blocks that look like finder patterns. The encoder applies each of eight masks, scores the result with four penalty rules and keeps the lowest score. The mask index is written into the format information so the decoder can reverse it.
Penalty rules in brief
The standard scores runs of five or more same-color modules, same-color 2×2 blocks, finder-like 1:1:3:1:1 sequences and an imbalance between dark and light modules. Masks are not a user setting in normal tools — the encoder decides — but they explain why two encoders can render visibly different patterns for the same payload.
Frequently asked questions
Can I choose a mask manually?
Some libraries expose the option, mostly for testing or artistic effects. The default automatic choice is the one that scans best.
Does the mask change the payload?
No. It is a reversible XOR applied after encoding; the decoded content is identical.
Why do two QR codes for the same URL look different?
Different encoders may segment the payload differently, choose a different mask or pick a different error-correction level.