WikiPlus

How QR Codes Work: The Technical Explanation

QR codes look like random noise to the human eye, but they are actually a precisely structured 2D matrix with a defined encoding scheme, built-in error correction, and a format specifically designed to be decoded by optical scanners in any orientation. Understanding how they work helps you make better decisions when generating them — choosing the right error correction level, understanding why size matters, and knowing why some color combinations fail. This article explains the technical structure of a QR code in plain language.

The Anatomy of a QR Code

A QR code is a square grid of black and white modules (small squares). Every part of that grid has a specific purpose defined by the ISO/IEC 18004 standard, which is the international specification for QR codes. Finder patterns are the three large square targets in the top-left, top-right, and bottom-left corners. Each consists of a 7×7 dark square, a 5×5 white square inside it, and a 3×3 dark square at the center. These targets allow the scanner to locate the code and determine its orientation — you can hold the phone at any angle and the scanner will still find the code correctly. Alignment patterns are smaller square targets that appear in larger QR versions (those encoding more data). They help the scanner correct for distortion when the code is printed on a curved surface or photographed at an angle. Timing patterns are alternating black and white stripes running horizontally and vertically between the finder patterns. They help the scanner establish the grid coordinates of each module. The format information area, adjacent to the finder patterns, stores the error correction level and the mask pattern applied to the data. This area is the first thing the scanner reads after locating the code. The data region is the remaining area of the grid, which stores the encoded payload and the error correction codewords. The data is read in a zigzag pattern from the bottom-right corner, column by column. All of these structural elements are present in every valid QR code, regardless of size or content. The version of the code (version 1 through 40) determines the total grid size and maximum data capacity — version 1 is 21×21 modules and can hold 41 alphanumeric characters; version 40 is 177×177 modules and can hold 4,296 alphanumeric characters.

How Data Is Encoded Inside a QR Code

The content you type into a QR generator does not get stored as raw text in the grid. It goes through a multi-step encoding process before being laid out as modules. First, the encoder selects a mode based on the content type. Numeric mode (digits 0–9 only) is the most compact, encoding 3 digits per 10 bits. Alphanumeric mode handles 0–9, A–Z, and a handful of special characters, encoding 2 characters per 11 bits. Byte mode handles any character via UTF-8 or ISO-8859-1 encoding, at 8 bits per character. Kanji mode handles Japanese characters with a specialized encoding. The encoder automatically selects the mode that minimizes the total bit count for your input. Next, the data bits are padded to fill the required number of codewords for the chosen version and error correction level. Then Reed-Solomon error correction codewords are calculated and appended. These are the mathematical backbone of the QR system — they allow the decoder to reconstruct damaged or obscured modules. Finally, a mask pattern is applied to the data region. There are 8 possible masks, each a different mathematical pattern that flips certain modules from dark to light. The encoder evaluates all 8 and selects the one that produces the most balanced dark/light distribution. This is necessary because a large block of solid dark or light modules is harder for scanners to decode accurately. The selected mask index is stored in the format information area. The resulting bit sequence is then written into the grid in the zigzag reading order, module by module. What looks like random noise is actually this carefully constructed, error-corrected, masked data payload.

Reed-Solomon Error Correction: How QR Codes Survive Damage

The most impressive technical feature of QR codes is their ability to decode correctly even when part of the pattern is damaged, obscured, dirty, or poorly printed. This is made possible by Reed-Solomon error correction, the same algorithm used in CDs, DVDs, Blu-ray discs, and deep-space communication systems. Reed-Solomon works by treating the data as a polynomial and computing additional codewords (the error correction bytes) that encode relationships between the data codewords. If some codewords are lost or corrupted, the decoder can use the remaining correct codewords and the error correction bytes to reconstruct the missing values mathematically — up to the limit of the chosen error correction level. For QR codes: Level L recovers up to 7% of lost codewords. Level M recovers up to 15%. Level Q recovers up to 25%. Level H recovers up to 30%. Higher levels add more error correction codewords, which takes up space in the data region. For a fixed amount of payload data, higher correction requires a larger QR version (bigger grid). Conversely, for a fixed version, higher correction reduces the maximum payload. This is why you can place a logo in the center of a level-H code and it still scans: the obscured modules correspond to corrupted codewords, and the Reed-Solomon algorithm reconstructs them from the surrounding codewords. You are effectively trading some of the 30% damage budget for the logo. The same principle explains why a code with a small smudge, slight misprint, or crease from folding still scans — the damage falls within the recoverable threshold.

Why QR Codes Are Better Than Barcodes for Most Uses

Traditional 1D barcodes (like EAN-13 on supermarket products) dominated for decades because they were the only practical machine-readable format for optical scanners. QR codes — invented by Denso Wave in Japan in 1994 — introduced a fundamentally different architecture that solves many limitations of 1D barcodes. Data capacity: a standard EAN-13 barcode stores exactly 13 digits. A QR code can store up to 4,296 alphanumeric characters or 7,089 numeric characters — orders of magnitude more data in a comparable footprint. Orientation independence: 1D barcodes must be aligned with the scanner beam. QR codes can be scanned in any orientation — sideways, upside down, at an angle — because the finder patterns allow the decoder to establish orientation before reading the data. Error correction: 1D barcodes have no built-in error correction. A single damaged module (dirty barcode, wrinkled label) causes a scan failure. QR codes recover from up to 30% damage. Smartphone readability: 1D barcodes require a laser or CCD scanner aligned with the stripes. QR codes are designed to be captured by a camera — any camera, including the rear camera of any smartphone. This is why QR codes became the standard for consumer-facing applications while 1D barcodes remain dominant in supply chain and retail inventory. For consumer marketing, event management, and information sharing, QR codes are the clear choice. For supply chain tracking, healthcare, and retail inventory management, 1D and 2D barcodes (including QR) coexist depending on the scanning infrastructure in place.

Frequently Asked Questions

Who invented the QR code and when?
The QR code was invented by Masahiro Hara and a team at Denso Wave, a subsidiary of Toyota, in 1994. It was originally designed to track automotive parts in manufacturing. Denso Wave holds the patent but chose not to exercise it, making QR codes freely usable by anyone. The standard was later formalized as ISO/IEC 18004. Widespread consumer adoption only came after smartphones with integrated cameras became mainstream, accelerating sharply after 2017 when iOS added native QR scanning to the Camera app.
What is the maximum amount of data a QR code can store?
A version 40 QR code (177×177 modules) at error correction level L can store up to 7,089 numeric characters, 4,296 alphanumeric characters, 2,953 bytes of binary data, or 1,817 Kanji characters. In practice, QR codes used for URLs and contact information use much smaller versions. A typical URL of 50–100 characters fits in a version 3 or 4 code (29×29 or 33×33 modules), which produces a much cleaner, easier-to-scan pattern.
Can a QR code be read by a standard barcode scanner?
A traditional 1D laser barcode scanner cannot read QR codes — the laser is designed for linear barcodes only. However, most modern 2D barcode scanners and imaging scanners (including those used in retail, logistics, and warehouses) can read both 1D and QR codes. All modern smartphones with a camera can scan QR codes natively. For consumer applications, a smartphone is the expected scanner.