How Do QR Codes Work? An Interactive Demo

2024-10-24

TechnologyOperationsInventory Management

Read Time: 10 minutes

What Are QR Codes?

A QR code (Quick Response code) is a two-dimensional barcode, also known as a matrix barcode, that stores information in both vertical and horizontal patterns. This enables QR codes to store considerably more data than traditional linear barcodes—up to several hundred times more.

Invented in 1994 by Masahiro Hara at Denso Wave, a Toyota subsidiary, QR codes were originally designed to track automotive parts during manufacturing. The "Quick Response" name reflects their primary advantage: they can be decoded approximately ten times faster than traditional barcodes. Unlike one-dimensional barcodes that can only be read horizontally, QR codes can be scanned from any angle, making them far more practical for real-world applications.

Today, QR codes are ubiquitous—found on product packaging, restaurant menus, event tickets, business cards, and even gravestones. Their ability to bridge the physical and digital worlds has made them an essential tool in modern commerce and communication.

How QR Codes Encode Information

At their core, QR codes work by converting data into a binary format (ones and zeros), then representing that binary data as a pattern of dark and light modules (squares). Each module represents a single bit: dark modules typically represent 1, and light modules represent 0.

The encoding process follows these steps:

  1. Mode Selection: The encoder determines the most efficient way to represent your data (numeric, alphanumeric, byte, or kanji)
  2. Data Encoding: The input text is converted to binary according to the selected mode
  3. Error Correction: Reed-Solomon codes are calculated and appended to protect against damage
  4. Structure Creation: The data is arranged into the QR code matrix with all required patterns
  5. Masking: A pattern is applied to ensure the code is easily scannable

QR Code Components

Every QR code contains several distinct regions, each serving a specific purpose. Understanding these components helps explain why QR codes are so robust and versatile.

  • Finder Patterns: The three large squares in the corners (top-left, top-right, bottom-left) that allow scanners to quickly locate and orient the code. These distinctive patterns can be recognized from any angle and at various distances.
  • Alignment Patterns: Smaller squares that appear in larger QR codes (version 2 and above) to help correct for distortion when the code is printed on curved surfaces or photographed at an angle.
  • Timing Patterns: Alternating dark and light modules running horizontally and vertically between the finder patterns. These help the scanner determine the size of individual modules.
  • Format Information: Data stored near the finder patterns that tells the scanner which error correction level and mask pattern were used.
  • Data and Error Correction: The remaining area contains the actual encoded information plus redundant data for error recovery.
  • Quiet Zone: The white border around the code (at least 4 modules wide) that helps scanners distinguish the code from its surroundings.

Data Storage Capacity by Mode

QR codes support four encoding modes, each optimized for different types of data. The encoder automatically selects the most efficient mode, or you can mix modes within a single code to maximize capacity.

Mode Max Capacity Bits per Character
Numeric 7,089 digits 3.33 bits
Alphanumeric 4,296 characters 5.5 bits
Binary (Byte) 2,953 bytes 8 bits
Kanji 1,817 characters 13 bits

Numeric mode is most efficient for data containing only digits 0-9. Three digits are encoded together into 10 bits, making it ideal for phone numbers, serial numbers, or numeric IDs.

Alphanumeric mode supports uppercase letters A-Z, digits 0-9, and nine special characters (space, $, %, *, +, -, ., /, :). Two characters are encoded into 11 bits. Note that lowercase letters require byte mode.

Byte mode encodes data as raw 8-bit bytes, supporting the full ISO-8859-1 character set or UTF-8 for international text. This is the most versatile mode but uses the most space.

QR Code Versions and Size

QR codes come in 40 different sizes called "versions." Version 1 is the smallest at 21×21 modules, and each subsequent version adds 4 modules per side. Version 40, the largest, measures 177×177 modules.

The version is automatically selected based on the amount of data and the error correction level. More data or higher error correction requires a larger version. In the interactive generator below, you can see how changing the content length or error correction affects the QR code version.

Error Correction: The Magic of Reed-Solomon

One of the most remarkable features of QR codes is their ability to remain scannable even when partially damaged or obscured. This is achieved through Reed-Solomon error correction, the same technology used in CDs, DVDs, and deep-space communication.

Reed-Solomon works by adding redundant data calculated through polynomial mathematics over finite fields (specifically, Galois fields). When a scanner reads a damaged code, it can use this redundant information to reconstruct the missing or corrupted data.

  • L (Low): ~7% of codewords can be restored. Best for clean environments where maximum data capacity is needed.
  • M (Medium): ~15% recovery. The default level, suitable for most applications.
  • Q (Quartile): ~25% recovery. Good for industrial environments or outdoor use.
  • H (High): ~30% recovery. Essential for codes that will have logos embedded or may face significant wear.

The trade-off is clear: higher error correction means less space for actual data. A Version 10 QR code with Level L correction can store 652 alphanumeric characters, but with Level H, only 346 characters fit.

Real-World Applications

The versatility of QR codes has led to their adoption across virtually every industry. Here are some of the most impactful uses:

Contactless Payments and India's UPI Revolution

Nowhere is the power of QR codes more evident than in India's Unified Payments Interface (UPI). Launched in 2016, UPI has transformed how over a billion people transact daily. In 2024, UPI processed over 14 billion transactions per month—more than all card payments in India combined.

The brilliance of UPI lies in its simplicity: every merchant, from multinational retailers to neighbourhood chai wallahs, displays the same standardized QR code. Customers scan with any UPI app (Google Pay, PhonePe, Paytm, or their bank's app), enter the amount, and authenticate with their PIN. Money moves instantly between bank accounts, 24/7, with zero transaction fees for consumers.

This QR-first approach leapfrogged card infrastructure entirely. A vegetable vendor who could never afford a card terminal now accepts digital payments with just a printed QR code. The National Payments Corporation of India (NPCI) estimates that UPI has brought over 300 million previously unbanked Indians into the digital economy—a financial inclusion success story built on the humble QR code.

Product Traceability

From farm to table, QR codes enable complete supply chain transparency. Consumers can scan a code on food packaging to see where ingredients were sourced, when they were harvested, and how they were processed. This builds trust and helps identify contamination sources during recalls.

Authentication and Anti-Counterfeiting

Luxury goods, pharmaceuticals, and electronics manufacturers embed unique QR codes that link to verification databases. Scanning confirms whether a product is genuine, protecting both brands and consumers from counterfeits.

Digital Documentation

COVID-19 vaccination certificates, event tickets, boarding passes, and educational credentials increasingly use QR codes for verification. The code contains or links to cryptographically signed data that proves authenticity.

IoT and Smart Manufacturing

In industrial settings, QR codes on equipment, parts, and workstations provide instant access to maintenance records, operating procedures, and real-time sensor data. Workers simply scan to access the information they need.

Best Practices for QR Code Design

  • Size Matters: Ensure the code is large enough to scan reliably. As a rule of thumb, the scanning distance should be about 10 times the width of the code.
  • Contrast is Critical: Dark modules on a light background works best. Avoid low-contrast color combinations.
  • Test Before Printing: Always verify scannability with multiple devices before mass production.
  • Use Appropriate Error Correction: If adding a logo or expecting wear, use Level Q or H.
  • Keep URLs Short: Shorter data means smaller codes that are easier to scan. Use URL shorteners for long links.
  • Provide Context: Include a call-to-action like "Scan for menu" so users know what to expect.

Advanced QR Code Techniques

Embedding Logos

One of the most popular customizations is placing a logo in the center of a QR code. This works because of error correction—the logo effectively "damages" part of the code, but with Level H correction, up to 30% of the code can be obscured while remaining scannable.

For best results, keep the logo small (under 30% of the code area), use Level H error correction, and ensure strong contrast between the logo and surrounding modules.

Color Customization

While traditional QR codes are black and white, they can use any colors with sufficient contrast. The key rule: dark modules should be at least 40% darker than light modules. Use the color pickers in the generator below to experiment—but always test the result with multiple scanning apps.

Dynamic QR Codes

Static QR codes contain fixed data, but dynamic QR codes encode a short URL that redirects to your actual destination. This allows you to change where the code points after printing, track scan analytics, and A/B test different landing pages—all without reprinting.

Artistic QR Codes

Advanced designers push QR codes further by modifying module shapes (rounded corners, dots, or custom patterns), integrating the code into artwork, or using gradient colors. These artistic codes sacrifice some scannability for aesthetics, requiring careful testing.

How QR Code Scanning Works

When you point your phone at a QR code, a sophisticated process happens in milliseconds:

  1. Detection: The camera captures the image, and software searches for the distinctive finder patterns—those three corner squares. Their unique ratio of dark:light:dark:light:dark (1:1:3:1:1) makes them instantly recognizable.
  2. Orientation: The positions of the three finder patterns reveal the code's orientation. The fourth corner (bottom-right) lacks a finder pattern, which tells the scanner which way is "up."
  3. Sampling Grid: Using the timing patterns and alignment patterns, the scanner creates a virtual grid over the image, determining where each module's center should be.
  4. Module Reading: Each grid cell is sampled to determine if it's dark or light, converting the image into binary data.
  5. Format Decoding: The format information near the finder patterns reveals the error correction level and mask pattern used.
  6. Unmasking: The mask pattern is reversed to reveal the actual data bits.
  7. Error Correction: Reed-Solomon decoding detects and corrects any errors in the data.
  8. Data Extraction: Finally, the binary data is converted back into the original text, URL, or other content.

Modern smartphones can complete this entire process dozens of times per second, enabling smooth real-time scanning even with camera movement.

Interactive QR Generator

Try out the interactive QR code generator below. Adjust the parameters to see how they affect the generated code.

The Future of QR Codes

Despite being three decades old, QR codes continue to evolve. New variants like Micro QR (for smaller spaces), iQR (irregular shapes), and SQRC (with private data layers) address specific use cases. Frame QR allows for custom center areas perfect for branding.

As augmented reality matures, QR codes may serve as triggers for immersive experiences—scan a product to see a 3D model, or scan a poster to watch it come alive. Their role as a bridge between physical and digital worlds is only expanding.

For businesses, QR codes represent one of the most cost-effective ways to add digital interactivity to physical products and spaces. They require no special hardware, work on any smartphone, and can be updated instantly when using dynamic codes.

Conclusion

QR codes are a remarkable piece of engineering—simple enough to print on any surface, yet sophisticated enough to survive damage and encode substantial amounts of data. Understanding how they work helps you use them more effectively, whether you're adding them to marketing materials, implementing them in a manufacturing process, or building them into a software application.

The interactive generator above demonstrates these concepts in action. Experiment with different settings to see how content length affects code complexity, how error correction trades capacity for resilience, and how colors can be customized while maintaining scannability.

Ready to Transform Your Operations?

See how IoTReady can help you achieve operational excellence.

Get in Touch