How QR Codes Work: A Complete Technical Explainer
The full story of QR codes — how data is encoded in the pattern, the different types of QR codes, error correction levels, and how to create effective QR codes for any purpose.
December 26, 2024
QR codes are everywhere — restaurant menus, product packaging, event tickets, business cards, and public health campaigns. Yet for most people, they remain mysterious black-and-white squares that somehow make a phone do things. This guide demystifies how QR codes work, the different types that exist, and how to create effective ones for any purpose.
What is a QR Code?
QR stands for Quick Response. It is a two-dimensional barcode created by Japanese engineer Masahiro Hara at Denso Wave in 1994, originally designed to track automotive parts during manufacturing. Unlike traditional 1D barcodes which encode data in a single row of lines, QR codes encode data in a 2D grid of black and white squares, allowing them to store far more information.
A typical QR code can store:
- Up to 7,089 numeric characters, or
- Up to 4,296 alphanumeric characters, or
- Up to 2,953 bytes of binary data
In practice, most QR codes store URLs (the most common use), contact information (vCards), Wi-Fi credentials, or short text strings.
The Structure of a QR Code
A QR code consists of several functional regions:
Finder Patterns
The three large squares in the corners (top-left, top-right, bottom-left) are called finder patterns. They allow QR code scanners to detect and orient the code regardless of the scanning angle. The fourth corner (bottom-right) has a smaller alignment pattern in larger QR codes.
Timing Patterns
Alternating black and white modules running horizontally and vertically between the finder patterns help the scanner determine the module size and grid alignment.
Format Information
Cells adjacent to the finder patterns encode the error correction level and the data masking pattern used — information the scanner needs before it can decode the data.
Data and Error Correction
The remaining cells contain the actual encoded data, interspersed with error correction codewords. Multiple data masking patterns are evaluated and the one producing the most balanced distribution of black/white modules is selected (to help scanners avoid confusing data for structural patterns).
Error Correction: Why QR Codes Work When Damaged
One of QR codes' most remarkable features is their ability to be read even when partially damaged, obscured, or covered by a logo. This is achieved through Reed-Solomon error correction, a mathematical redundancy algorithm that can reconstruct missing data.
QR codes support four error correction levels:
- L (Low) — 7% of data can be restored. Smallest code, most fragile.
- M (Medium) — 15% of data can be restored. Good balance.
- Q (Quartile) — 25% of data can be restored. Good for industrial use.
- H (High) — 30% of data can be restored. Required for QR codes with logos.
Higher error correction = larger QR code (more modules needed for redundancy). When adding a logo to a QR code, always use Level H to ensure the code remains scannable even with significant data obscured.
QR Code Versions
QR codes come in 40 "versions" (sizes), from Version 1 (21×21 modules) to Version 40 (177×177 modules). The version is automatically selected based on data length and error correction level. Shorter data = smaller, simpler QR code = easier and faster to scan.
This is why URL shorteners are popular for QR codes — shorter URLs produce simpler QR codes that scan more reliably at smaller print sizes.
Types of QR Codes
Static QR Codes
The data is encoded directly in the QR code. The destination is fixed — once printed, it cannot be changed. Ideal for permanent content (physical addresses, Wi-Fi credentials, contact cards). This is what free online generators create.
Dynamic QR Codes
The QR code contains a short URL to a redirect service. The destination URL can be updated without reprinting the QR code. Dynamic QR codes also typically include scan analytics (location, device, time). Require a paid service — common for marketing campaigns.
What QR Codes Can Encode
- URL — Opens a website. Most common use.
- vCard — Adds a contact to the phone's address book.
- Wi-Fi credentials — Connects a phone to a Wi-Fi network automatically.
- Plain text — Displays a text message.
- Email — Opens the email app with a pre-filled recipient and subject.
- SMS — Opens the messaging app with a pre-filled number and message.
- Phone number — Initiates a phone call.
- Calendar event — Adds an event to the phone's calendar.
- Cryptocurrency payment — Encodes a wallet address and optional amount.
Best Practices for Creating Effective QR Codes
- Use a short URL — Shorter data = simpler code = faster scanning. Use a URL shortener or ensure the destination URL is concise.
- Minimum print size: 2×2cm — QR codes smaller than 2cm square become difficult to scan reliably. Include a quiet zone (white border) equal to 4 module widths.
- High contrast — Dark modules on a light background. Avoid using colors that reduce contrast (yellow on white, dark gray on black).
- Test before printing — Always test your QR code with multiple smartphones and QR scanner apps before printing at scale.
- Link to mobile-optimized content — QR codes are almost exclusively scanned on smartphones. Ensure the destination page is mobile-friendly.
Summary
QR codes encode data in a 2D grid of modules using Reed-Solomon error correction that allows them to be read even when partially damaged. Static QR codes embed data directly; dynamic QR codes point to a redirect service for tracking and editability. For most uses, Level H error correction with a short URL produces the most scannable, versatile result. Test on multiple devices before committing to print.