Skip to content
Fundamentals

How QR Codes Work — The Complete Guide to QR Code Encoding, Scanning, and Error Correction

Learn how QR codes work — from data encoding and error correction to scanning. Understand the science behind QR code generation in plain language.

8 min readJanuary 15, 2026
How QR codes work — smartphone scanning a QR code with data encoding visualization
How QR codes work — smartphone scanning a QR code with data encoding visualization

QR Codes Are Everywhere — But How Do They Actually Work?

You scan QR codes every day — at restaurants, on products, at payment counters. But have you ever wondered what actually happens when you point your phone at that square pattern? That tiny black-and-white grid carries more engineering than most people realize. It encodes data, corrects its own errors, and communicates with your camera in milliseconds — all without a single wire or network connection.

Understanding how QR codes work isn't just a curiosity. If you're a business owner printing QR codes on packaging, a developer integrating QR scanning into an app, or simply someone who wants to know why a code won't scan, knowing the mechanics behind QR codes helps you create better ones and troubleshoot problems faster.

In this guide, we'll break down the entire QR code lifecycle — from data encoding to the moment your phone reads it — in plain language. No jargon, no fluff, just the real science made simple.

What Is a QR Code?

A QR code (short for Quick Response code) is a two-dimensional barcode invented in 1994 by Masahiro Hara, an engineer at Denso Wave, a Japanese automotive company. The original purpose was to track vehicle parts during manufacturing. Traditional barcodes could only hold about 20 characters, and workers had to scan multiple barcodes per part. Hara's team designed a code that could hold vastly more data and be read at high speed — hence "Quick Response."

A QR code stores information in a grid of black and white squares called modules. Unlike a traditional one-dimensional barcode, which encodes data only horizontally, a QR code encodes data both horizontally and vertically. That two-dimensional approach is what gives QR codes their much higher data capacity.

Today, QR codes are everywhere — restaurant menus, payment terminals, event tickets, boarding passes, product labels, and business cards. The technology that was built for factory floors now powers daily consumer interactions worldwide.

The Anatomy of a QR Code

When you look at a QR code, you're not just looking at a random scatter of squares. Every region has a specific job. Here's what each part does:

  • Finder patterns — The three large squares in the top-left, top-right, and bottom-left corners. These tell the scanner, "This is a QR code," and help the camera determine the code's orientation and position. Without these, your phone wouldn't even know it was looking at a QR code.
  • Alignment pattern — A smaller square near the bottom-right corner (present in Version 2 and above). It helps the scanner read a QR code that's distorted, tilted, or on a curved surface. Larger QR codes have multiple alignment patterns.
  • Timing patterns — Alternating black and white modules that run between the finder patterns. They help the scanner determine the size of the module grid, essentially telling the reader how many columns and rows the data occupies.
  • Format information — Strips of data near the finder patterns that store the error correction level and the mask pattern used. This is critical metadata — without it, the scanner can't decode the rest of the code.
  • Version information — Present in Version 7 and above, this area tells the scanner which QR code version (size) is being used. There are 40 versions in total.
  • Data and error correction modules — The bulk of the QR code. This is where your actual encoded data lives, along with the error correction codewords that allow the code to survive damage.
  • Quiet zone — The blank white border around the QR code. It's not decoration — scanners need this empty space to distinguish the QR code from its surroundings. The quiet zone must be at least four modules wide.

Each of these elements plays a precise role in making sure your phone can read the code quickly and accurately, even under less-than-ideal conditions.

QR code anatomy diagram showing finder patterns, alignment patterns, and data modules
QR code anatomy diagram showing finder patterns, alignment patterns, and data modules

How Data Gets Encoded in a QR Code

Encoding is the process of converting your input — a URL, text, phone number, or other data — into the pattern of black and white modules. Here's how it works step by step:

  1. Data analysis — The encoder analyzes your input to determine the most efficient encoding mode. QR codes support four modes: Numeric (digits only), Alphanumeric (digits, uppercase letters, and a few symbols), Byte (full ASCII/UTF-8), and Kanji (Japanese characters). Choosing the right mode is critical — Numeric mode can store up to 7,089 characters, while Byte mode maxes out at 2,953.
  2. Data encoding — Your input is converted into a bit stream according to the chosen mode. For example, in Numeric mode, groups of three digits are encoded into 10 bits. In Byte mode, each character takes 8 bits.
  3. Error correction — Error correction codewords are generated using Reed-Solomon error correction. This is the same algorithm used in CDs and deep-space communication. You can choose from four levels: L (7% recovery), M (15%), Q (25%), and H (30%). Higher levels mean more resilience but less data capacity.
  4. Module placement — The bit stream is placed into the QR code grid in a specific zigzag pattern, starting from the bottom-right corner and moving upward in two-column strips. The functional patterns (finder, alignment, timing) are already reserved, so data fills only the remaining modules.
  5. Masking — The encoder applies one of eight mask patterns to the data area. Masking inverts certain modules to avoid patterns that confuse scanners — like large blocks of the same color or patterns that look like finder patterns. The encoder tests all eight masks and picks the one that produces the best readability score.
  6. Format and version information — Finally, the format string (error correction level + mask pattern) and version information are written into their reserved areas.

The result is a carefully optimized grid that your phone's camera can decode in milliseconds.

How QR Code Scanning Works

The scanning process is essentially encoding in reverse — but with a few extra challenges, because the real world is messy. Here's what happens when you point your camera at a QR code:

  1. Image capture — Your phone's camera captures a frame. Modern phones use high-speed sensors and autofocus to grab a clear image even in motion.
  2. Finder pattern detection — The scanning algorithm scans the image for the three finder patterns. It looks for the characteristic 1:1:3:1:1 ratio of black and white modules in the outer rings. This ratio is what makes QR codes instantly recognizable to software.
  3. Perspective correction — The scanner uses the positions of the three finder patterns to calculate a perspective transformation. This is how your phone can read a QR code that's tilted, at an angle, or on a curved surface. The code gets mathematically "flattened" before decoding.
  4. Format reading — The scanner reads the format information to determine the error correction level and mask pattern.
  5. Unmasking — The mask pattern is reversed to reveal the original data modules.
  6. Data decoding — The bit stream is read following the zigzag pattern, error correction is applied (and any damaged data is reconstructed), and the original data is output — a URL, text string, contact card, or whatever was encoded.

All of this happens in roughly 100 to 300 milliseconds on a modern smartphone. The engineering is invisible, but it's what makes the experience feel instant.

Why QR Codes Replaced Barcodes

Traditional one-dimensional barcodes — the kind you see on grocery items — have served retail well since the 1970s. But they have significant limitations that QR codes solve:

  • Data capacity — A standard UPC barcode holds about 20 characters. A QR code can hold up to 7,089 numeric characters or 2,953 bytes. That's a 350x improvement.
  • Encoding flexibility — Barcodes are limited to numbers and a few symbols. QR codes can encode URLs, multi-language text, vCard contact information, Wi-Fi credentials, and more.
  • Error correction — If a barcode is scratched or torn, it's unreadable. QR codes with Reed-Solomon error correction can survive up to 30% damage and still function perfectly.
  • Omnidirectional scanning — Barcodes must be scanned from a specific orientation. QR codes can be scanned from any angle thanks to the finder patterns.
  • Readability — Barcodes require specialized laser scanners. QR codes can be read by any smartphone camera, no extra hardware needed.

This is why QR codes have become the default for everything from restaurant menus to boarding passes — they're simply more capable, more resilient, and more accessible than barcodes.

QR Code Versions and Sizes

Not all QR codes are the same size. The QR code specification defines 40 versions, ranging from Version 1 (21×21 modules) to Version 40 (177×177 modules). Each version increases the grid by 4 modules per side.

Here's a practical breakdown:

  • Version 1–3 (21×21 to 29×29) — Ideal for short URLs, phone numbers, and simple text. These are the most common QR codes you see in daily life.
  • Version 4–10 (33×33 to 57×57) — Suitable for longer URLs with UTM parameters, vCard contact details, or short paragraphs of text.
  • Version 11–20 (61×61 to 97×97) — Used for Wi-Fi credentials, longer text, or data that needs high error correction.
  • Version 21–40 (101×101 to 177×177) — Reserved for very large data payloads. These are rare in consumer use and can be harder to scan because of the density of modules.

For most practical purposes, you'll never need to choose a version manually. When you use QREndlessPro's free QR code generator, the tool automatically selects the smallest version that fits your data, keeping your QR code as small and scannable as possible.

How Fast Can a QR Code Be Scanned?

The speed of QR code scanning depends on several factors — and understanding them helps you create codes that scan reliably:

  • Module size — Larger modules are easier for cameras to resolve. A QR code printed at 2 cm × 2 cm will scan faster than one at 1 cm × 1 cm, assuming the same viewing distance.
  • Error correction level — Higher error correction levels (Q, H) add more data to the code, making it denser and slightly slower to scan. Use level L or M for simple URLs, and reserve H for codes that might be damaged (like on printed materials).
  • Contrast — Black on white scans fastest. Low-contrast designs (like light gray on white) can dramatically increase scan time or cause failures. If you want to customize your code's appearance, use QREndlessPro's QR code customizer to adjust colors while maintaining sufficient contrast.
  • Surface and lighting — Curved surfaces, glossy materials, and uneven lighting all slow down scanning. Matte surfaces with even lighting are ideal.
  • Camera quality — Modern smartphones with autofocus and high-resolution sensors can scan QR codes in under 100 ms. Older phones or low-resolution webcams may take 500 ms or more.

Under optimal conditions — a flat, high-contrast QR code scanned with a modern smartphone — the entire process from camera capture to data output takes about 100 to 300 milliseconds. That's faster than a human blink.

QR Code Capacity: How Much Data Can They Hold?

One of the most common questions about QR codes is how much data they can store. The answer depends on the encoding mode and error correction level:

  • Numeric mode — Up to 7,089 digits (at error correction level L)
  • Alphanumeric mode — Up to 4,296 characters (digits, uppercase A–Z, and a few symbols)
  • Byte mode — Up to 2,953 bytes (full UTF-8, including lowercase letters and special characters)
  • Kanji mode — Up to 1,817 characters (Japanese double-byte characters)

However, just because a QR code can hold that much data doesn't mean it should. Larger data payloads create denser QR codes that are harder to scan, especially at smaller print sizes. The best practice is to encode the minimum amount of data necessary — use a short URL instead of a long one, and link to a page rather than embedding full text.

Creating Your Own QR Codes

Now that you understand how QR codes work under the hood, creating them becomes much more intentional. You know why error correction matters, why contrast is critical, and why simpler codes scan faster.

With QREndlessPro's free QR code generator, you can create any of these QR code types in seconds — no sign-up, 100% browser-based. Need to generate hundreds at once? The bulk QR code generator handles that too. Want to decode an existing QR code from an image? Try the QR code decoder to see exactly what data it contains.

For more on specific topics, check out our guides on QR code error correction and whether your QR code is secure.

FAQ

What is a QR code and how does it work?

A QR code is a two-dimensional barcode that stores data in a grid of black and white modules. It works by encoding your input (like a URL or text) into a binary bit stream, adding error correction data, arranging the bits into a grid pattern, and applying a mask for readability. When scanned, the camera detects the finder patterns, reads the data modules, applies error correction, and decodes the original information — all in milliseconds.

How do QR codes store data?

QR codes store data as binary bits arranged in a grid of modules (the small squares). Each module represents a 1 (black) or 0 (white). The data is encoded using one of four modes — Numeric, Alphanumeric, Byte, or Kanji — depending on the type of content. Error correction codewords are added using Reed-Solomon encoding, allowing the code to be read even if partially damaged.

Why do QR codes have three squares in the corners?

Those three squares are called finder patterns. They serve a critical purpose: they tell the scanner that it's looking at a QR code and help the camera determine the code's orientation and position. Without them, the scanner wouldn't know where the QR code begins, what angle it's at, or how large it is. The three-corner placement allows the scanner to detect the code from any rotation.

Can a QR code work if it's damaged?

Yes, thanks to Reed-Solomon error correction. Depending on the error correction level used (L, M, Q, or H), a QR code can recover from 7% to 30% damage. A code with level H error correction can have nearly a third of its modules damaged and still be perfectly readable. This is why QR codes on outdoor signage, product packaging, and worn materials still work reliably.

How much data can a QR code hold?

The maximum capacity depends on the encoding mode and error correction level. At the lowest error correction level (L), a QR code can hold up to 7,089 numeric digits, 4,296 alphanumeric characters, or 2,953 bytes of data. Higher error correction levels reduce capacity but increase resilience. For most practical uses, a QR code with a URL or short text falls well within capacity limits.

Why are QR codes better than barcodes?

QR codes outperform traditional barcodes in several ways: they hold far more data (thousands of characters vs. about 20), they can encode diverse data types (URLs, text, contacts, Wi-Fi credentials), they include built-in error correction so they survive damage, they can be scanned from any angle, and they can be read by any smartphone camera without specialized hardware. These advantages are why QR codes have largely replaced barcodes for consumer-facing applications.

Share this article

Back to Blog

Related Articles