How QR Codes Work
QR codes pack a lot of engineering into those black and white squares. Let's explore how they actually work.
QR Code Structure
A QR code contains several functional regions:
┌─────────────────────────────┐
│ ▓▓▓▓▓▓▓ ░░░░░ ▓▓▓▓▓▓▓ │ Finder patterns
│ ▓░░░░░▓ ▓░░░░░▓ │ (corners)
│ ▓░▓▓▓░▓ ▓░▓▓▓░▓ │
│ ▓░▓▓▓░▓ ▓░▓▓▓░▓ │
│ ▓░░░░░▓ ▓░░░░░▓ │
│ ▓▓▓▓▓▓▓ ░▓░▓░ ▓▓▓▓▓▓▓ │ Timing patterns
│ ░░░░░ │
│ ░▓░▓░▓░ DATA ░▓░▓░▓░ │ Data region
│ AREA │
│ ▓▓▓▓▓▓▓ ░░░░░ ░░░░░░ │
│ ▓░░░░░▓ ░▓▓▓░ ░▓▓▓░░ │
│ ▓░▓▓▓░▓ │ Alignment pattern
└─────────────────────────────┘
Finder Patterns
The three large squares in corners help scanners:
- Locate the QR code
- Determine orientation
- Calculate the code's angle
Encoding Modes
QR codes support multiple encoding modes:
| Mode | Characters | Bits per char |
|---|
| Alphanumeric | A-Z, 0-9, symbols | 5.5 |
|---|
| Kanji | Japanese characters | 13 |
|---|
Error Correction
QR codes use Reed-Solomon error correction with four levels:
| Q | ~25% | Dirty/damaged likely |
|---|
This is why QR codes work even when partially damaged or obscured!
Version and Capacity
QR codes come in 40 versions (sizes):
| Version | Modules | Max Alphanumeric |
|---|
| 40 | 177×177 | 4,296 characters |
|---|
Masking
To ensure even distribution of dark/light modules, one of 8 mask patterns is applied. The encoder tests all patterns and picks the one with the best score.