How QR Codes Work

Understand the technology behind QR codes - from data encoding to scanning. Learn about QR code structure, versions, and why they're so reliable.

8 min read

Updated: December 2024

Technology
Encoding
Technical
Table of Contents
  • QR Code Anatomy

  • How Data is Encoded

  • QR Code Versions

  • How Scanning Works

  • Error Correction

  • FAQ

QR Code Anatomy

Every QR code is made up of several distinct components, each serving a specific purpose. Understanding these parts helps explain why QR codes are so reliable and can be scanned from any angle.

Finder Patterns

The three large squares in corners that help scanners locate and orient the QR code.

Alignment Patterns

Smaller squares that help correct distortion, especially in larger codes.

Timing Patterns

Alternating black/white lines between finder patterns that help determine module size.

Format Information

Contains error correction level and mask pattern used.

Version Information

Identifies the QR code version (size) for versions 7 and above.

Data & Error Correction

The actual encoded data plus redundancy for error recovery.

Quiet Zone

White border around the code that helps scanners identify edges.

How Data is Encoded

QR codes convert your data into a pattern of black and white modules (squares). The encoding process involves several steps:

  • 1. Mode Selection

    The encoder chooses the most efficient mode based on your data type: Numeric, Alphanumeric, Byte, or Kanji.

  • 2. Data Encoding

    Characters are converted to binary based on the selected mode. Numbers are most efficient, followed by alphanumeric.

  • 3. Error Correction

    Reed-Solomon error correction codes are calculated and added. This is what allows damaged codes to still work.

  • 4. Data Placement

    The binary data is placed in a specific zigzag pattern, avoiding the functional patterns (finders, timing, etc.).

  • 5. Masking

    A mask pattern is applied to balance the number of black and white modules, improving scannability.

Encoding Modes & Efficiency

Numeric: 0-9 only → 3.3 bits per character (most efficient)

Alphanumeric: 0-9, A-Z, space, $%*+-./: → 5.5 bits per character

Byte: Any character (UTF-8) → 8 bits per character

Kanji: Japanese characters → 13 bits per character

QR Code Versions

QR codes come in 40 different "versions," each with a different size. Version 1 is the smallest (21×21 modules), and Version 40 is the largest (177×177 modules). The version is automatically selected based on how much data needs to be encoded.

VersionSizeCapacity*Best For

Version 1

21×21~25Short URLs, simple text

Version 10

57×57~174Medium URLs, contact info

Version 20

97×97~858Long text, detailed vCards

Version 40

177×177~4,296Maximum data capacity
* Alphanumeric characters with Medium error correction

How Scanning Works

When you scan a QR code with your phone, here's what happens in milliseconds:

  • 1. Detection

    The camera detects the three finder patterns and locates the QR code in the image.

  • 2. Orientation

    Using the finder patterns, the scanner determines the code's rotation and perspective.

  • 3. Grid Sampling

    The timing patterns help establish a grid, and each module is sampled as black or white.

  • 4. Format Decoding

    The format information reveals the error correction level and mask pattern used.

  • 5. Data Extraction

    The scanner reads the data in the zigzag pattern, applies the mask, and extracts the binary.

  • 6. Error Correction

    Reed-Solomon decoding corrects any errors from damage or scanning issues.

  • 7. Content Delivery

    The decoded data is interpreted (URL, text, contact, etc.) and presented to the user.

Error Correction

One of QR codes' most powerful features is built-in error correction. Using Reed-Solomon error correction, QR codes can recover from damage, dirt, or even intentional modifications (like adding a logo).

L

Low

~7% recovery

M

Medium

~15% recovery

Q

Quartile

~25% recovery

H

High

~30% recovery

Frequently Asked Questions

Up to about 4,296 alphanumeric characters or 7,089 numeric digits at maximum capacity (Version 40 with Low error correction). Practical limits are lower for reliable scanning.

These are finder patterns. They help scanners quickly locate the QR code and determine its orientation, allowing codes to be scanned from any angle.

Yes! QR codes use Reed-Solomon error correction. Depending on the level chosen, up to 30% of the code can be damaged or obscured and still scan correctly.

QR code size (version) increases with data amount. More data requires more modules, resulting in a larger, denser code. Version 1 has 21×21 modules, Version 40 has 177×177.

Ready to Create Your QR Code?

Use our free QR code generator to create custom QR codes in seconds.

Create Your QR Code