How QR Codes Work: A Technical Deep Dive

Understanding the structure, encoding, and error correction that makes QR codes reliable.

technicalencodingdeep-dive

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:

ModeCharactersBits per char
Numeric0-93.33
AlphanumericA-Z, 0-9, symbols5.5
ByteAny (UTF-8)8
KanjiJapanese characters13

Error Correction

QR codes use Reed-Solomon error correction with four levels:

LevelRecoveryUse Case
L~7%Clean environments
M~15%General use
Q~25%Dirty/damaged likely
H~30%Maximum durability

This is why QR codes work even when partially damaged or obscured!

Version and Capacity

QR codes come in 40 versions (sizes):

VersionModulesMax Alphanumeric
121×2125 characters
1057×57395 characters
40177×1774,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.

Frequently Asked Questions

Common questions about this topic

The three finder patterns (large squares in corners) help scanners quickly locate and orient the QR code. Their unique pattern (black-white-black-white-black 1:1:3:1:1 ratio) doesn't appear elsewhere in valid QR codes, making detection reliable at any angle.

With the highest error correction level (H), QR codes can be read with up to 30% damage or obstruction. This is why logos can be placed in the center - as long as 70% of the code remains, it's readable. Lower error correction levels survive less damage but store more data.

Minimum module (square) size should be 2-4 pixels on screen, or 0.5mm in print. The overall code size depends on content and scanning distance. Rule of thumb: QR code should be 1/10th the scanning distance (10cm code for 1m distance). Always test with multiple devices.