Quick answer
A QR code (Quick Response code) is a 2D barcode that stores up to 2,953 bytes of data as a pattern of black modules on a white background. Three large squares in the corners (the finder patterns) help the scanner detect and orient the code. The remaining area is divided into a grid of data modules, format information, version information, and Reed-Solomon error-correction codewords. When a smartphone camera reads the code, it samples the grid, decodes the binary, applies error correction, and dispatches the result - usually a URL - to the browser, all in 100-300 milliseconds.
Anatomy of a QR code
A QR code is a square grid of small black or white squares called modules. The grid is surrounded by a white quiet zone (at least 4 modules wide on all sides) that helps the scanner distinguish the code from the background.
The grid contains several distinct regions, each with a specific role:
Finder patterns (position markers)
The three large concentric squares in the top-left, top-right, and bottom-left corners. Each is a 7x7 module pattern with a 3x3 black center, a 5x5 white ring, and a 7x7 black outer ring. The scanner looks for these first to confirm "this is a QR code" and to establish orientation. Because three corners are marked, the scanner can read the code correctly even if it is rotated 90, 180, or 270 degrees.
Alignment patterns
Smaller 5x5 concentric squares positioned in specific locations (depending on the version) to correct for distortion. When a QR code is printed on a curved surface - like a bottle of water or a cylindrical poster - the modules near the edges get stretched or compressed. Alignment patterns help the scanner mathematically correct for that distortion.
Timing patterns
Alternating black and white modules that run horizontally between the top-left and top-right finder patterns, and vertically between the top-left and bottom-left finder patterns. They tell the scanner the physical size of one module, so it knows how to sample the rest of the grid accurately even if the code is printed at a different size than expected.
Format and version information
Two small reserved regions that store the error-correction level (L, M, Q, or H) and the mask pattern (one of 8 pre-defined patterns XORed over the data to break up large blocks of same-color modules and improve scanner reliability). Version information is only present on QR codes Version 7 or higher (above 45x45 modules).
Data and error-correction modules
The remaining area holds two types of modules interleaved in a specific pattern: data codewords (your actual URL, text, or other content encoded as 8-bit bytes) and error-correction codewords (Reed-Solomon parity bytes that let the scanner recover the data even if some modules are damaged). The ratio between data and error-correction is what determines the four EC levels: L (7%), M (15%), Q (25%), H (30%).
QR code versions and capacity
The QR code standard defines 40 versions, each a different grid size. Version 1 is the smallest at 21x21 modules. Each subsequent version adds 4 modules per side, so Version 2 is 25x25, Version 10 is 57x57, and Version 40 is 177x177.
| Version | Grid size | Max chars (numeric, L) | Max bytes (binary, L) |
|---|---|---|---|
| 1 | 21x21 | 41 | 17 |
| 2 | 25x25 | 77 | 32 |
| 5 | 37x37 | 213 | 106 |
| 10 | 57x57 | 652 | 271 |
| 20 | 97x97 | 2,085 | 858 |
| 40 | 177x177 | 7,089 | 2,953 |
For typical URL QR codes, Version 2-5 covers most real-world URLs (under 100 characters). Longer URLs or data payloads (like vCards with full address) move toward Version 10-20. The encoder automatically selects the smallest version that fits your data and the chosen error-correction level.
Error correction: how QR codes survive damage
QR codes use Reed-Solomon error correction, the same algorithm used in CDs, DVDs, Blu-ray discs, and QR codes' spiritual cousin, the Data Matrix. The data is split into blocks, and for each block, a number of parity codewords are calculated. If some modules are damaged (a logo overlays the code, the print is scratched, or a finger covers part of it), the scanner can reconstruct the missing data from the parity.
The four QR error-correction levels are:
- L (Low, 7%): Maximum data capacity. Use for clean, undamaged environments with no logo overlay.
- M (Medium, 15%): Default for most use cases. Good balance of capacity and resilience.
- Q (Quartile, 25%): Recommended when adding a logo to the center of the code.
- H (High, 30%): Maximum resilience. Use for codes that will be exposed to damage, such as outdoor signage, industrial labels, or products that will be touched often.
Choosing a higher level reduces the data capacity of a given version but increases the chance of scanning. For most consumer-facing QR codes, M or Q is a good default.
Data encoding modes
QR codes can encode data in four modes, and the encoder picks the most efficient one for your content:
- Numeric (10 bits per 3 digits): Most efficient. Used for plain decimal numbers like phone numbers, ticket IDs, or short codes.
- Alphanumeric (11 bits per 2 chars): For uppercase letters, digits, and a few symbols. Common for SMS, WiFi credentials, and short URLs.
- Byte (8 bits per char): For arbitrary text or binary data. Default for URLs. Uses ISO 8859-1 for compatibility, with extensions for UTF-8.
- Kanji (13 bits per character): Optimized for Japanese characters. Rarely used outside Japan.
Modern encoders also support structured append (splitting data across multiple QR codes) and ECI modes (Extended Channel Interpretation for character set hints). The leading 4 bits of the data area indicate which mode is in use.
How a smartphone scans a QR code
The scan-and-decode process happens in less than a third of a second. Here is the simplified pipeline:
- Frame capture: The camera continuously captures 30-60 frames per second. The image-processing pipeline looks for the three finder patterns in each frame.
- Detection and orientation: When the three finder patterns are found, the scanner calculates the code's orientation, size, and position in 3D space (using the pattern's known 1:1:3:1:1 ratio).
- Perspective correction: The image is digitally un-wrapped into a flat square, correcting for the angle at which the code is held.
- Module sampling: The scanner converts the unwrapped image to a binary grid, sampling the center of each module to determine black or white.
- Format and version reading: The format and version information is decoded to determine the error-correction level and the mask pattern.
- Unmasking: The mask pattern is XORed over the data modules to recover the original encoding.
- Error correction: Reed-Solomon decoding recovers any missing or corrupted data. The scanner may retry from a different frame if the first attempt fails.
- Decoding: The data codewords are concatenated and split according to the encoding mode (numeric, alphanumeric, byte, or kanji) to produce the final string.
- Dispatch: The result - typically a URL - is passed to the operating system, which routes it to the browser, contact card handler, WiFi settings, or another appropriate app.
Frequently asked questions
How does a QR code store data?
A QR code stores data as a pattern of black and white squares. The pattern encodes binary data using 8-bit codewords arranged across the grid. There are 40 versions (sizes) of QR codes, ranging from 21x21 modules (Version 1) up to 177x177 modules (Version 40), storing up to 2,953 bytes of binary data at the lowest error correction level.
What are the three squares in a QR code?
The three large squares in the corners (top-left, top-right, bottom-left) are called finder patterns or position markers. They let the scanner identify the code as a QR code, determine its orientation (even when rotated), and establish the coordinate system for decoding the data modules.
How fast can a phone scan a QR code?
Modern smartphones scan and decode a QR code in 100-300 milliseconds. The camera captures multiple frames per second, runs image processing to find the finder patterns, applies perspective correction, then decodes the Reed-Solomon error-corrected data. With a clear code and good lighting, the entire process feels instantaneous.
What is the difference between QR code versions?
A QR code version determines the physical size of the grid. Version 1 is 21x21 modules. Each subsequent version adds 4 modules per side. Version 40 is 177x177. Larger versions store more data but require more space to print. The version is auto-selected by the encoder based on the data length and chosen error-correction level.
What does the small square in a QR code do?
The small square near the bottom-right corner is the alignment pattern. Unlike the three finder patterns (which are always in the same corners), alignment patterns appear in varying positions depending on the QR version. They help the scanner correct for distortion when the code is printed on a curved or angled surface, like a bottle or a sign viewed at an angle.
Can a damaged QR code still be scanned?
Yes, if the damage is within the error-correction tolerance. QR codes use Reed-Solomon error correction with four levels: L (7% recoverable), M (15% recoverable), Q (25% recoverable), and H (30% recoverable). A QR code with H-level correction can be scanned even if nearly a third of it is obscured, defaced, or missing.
A brief history of QR codes
Masahiro Hara, an engineer at the Japanese auto-parts company Denso Wave, invented the QR code in 1994. The original purpose was to track automotive components during manufacturing - the previous 1D barcodes could only store 20 alphanumeric characters, which was not enough for the complex data Denso needed to encode.
Hara's team designed QR codes to be scanned quickly from any angle, store significantly more data than 1D barcodes, and remain readable even when partially damaged. The "QR" in the name stands for "Quick Response" because the codes were designed for high-speed scanning.
Denso Wave released the QR code specification into the public domain in 1999, allowing anyone to implement it. The first QR code mobile scanner shipped in Japan in 2002. Adoption accelerated globally after the iPhone 3G (2008) included a QR reader in its camera, and Android 9 (2018) made the camera app scan QR codes natively. By 2020, the COVID-19 pandemic drove massive adoption as restaurants replaced physical menus with QR codes for contactless ordering.
Today, QR codes are scanned over 30 billion times per year globally, and the format is standardized internationally as ISO/IEC 18004.
Make your own QR code
Now that you understand the technical structure, you can create your own QR code in seconds with QRBuilt. The tool runs entirely in your browser (no data upload, no server) and lets you generate QR codes for URLs, text, vCards, WiFi, email, SMS, and phone, with customization for size, colors, and error-correction level.
Create Your Free QR Code