How Do QR Codes Work? A Simple Technology Guide
By the BrainSnail editorial team. How these articles are written and checked, and how to tell us when one is wrong.
A QR code stores data in a grid of small dark and light squares that a camera and decoding software can turn back into information. Special patterns help the reader find the code's position, understand its layout, and recover data even when part of the image is damaged.
A grid, not a line
QR stands for Quick Response. Unlike a one-dimensional barcode that mainly stores information along lines, a QR code uses a two-dimensional grid. That lets it hold more data in a compact space. The encoded information might be text, a web address, contact details, or another supported data format.
Not every square in the grid is part of the message itself. Large square finder patterns near three corners help software recognise the code and determine its orientation. Other fixed patterns help with alignment, timing, format information, and the structure needed to interpret the remaining modules correctly.
This layout is central to how QR codes work because a phone does not simply photograph a random checkerboard and guess. The decoder first identifies the code's geometry, corrects for rotation or perspective, reads structural information, and then extracts the encoded data.
How information becomes black and white squares
Before data is placed into the grid, it is converted into binary information. The encoder chooses a mode suited to the content, adds information about length and structure, and creates codewords that represent the message. It also generates extra error-correction data.
The bits are then arranged into available parts of the QR grid according to defined rules. A masking pattern is applied to avoid visual arrangements that would be difficult for scanners to read reliably, such as large blocks or misleading patterns. Information in the code tells the decoder which mask was used.
Learning this sequence makes how QR codes work much less mysterious. The visible pattern is the final result of several organised steps. The exact squares are not decorative. They represent message bits, recovery data, and structural information that lets many different readers interpret the same standard.
Why a damaged QR code can still scan
QR codes include error correction, which adds redundant information so some missing or incorrect data can be reconstructed:
- •Finder patterns help the camera locate and orient the code.
- •Timing and alignment patterns help reconstruct the grid accurately.
- •Data is encoded into binary codewords.
- •Error-correction codewords add recoverable redundancy.
- •Decoding software reverses the process to recover the original information.
This is why a code can sometimes scan despite a scratch, smudge, or small logo placed over part of it. The amount of damage that can be tolerated depends on the error-correction level and where the damage occurs. Covering a finder pattern or too much of the data can still make the code unreadable.
One safety note belongs with how QR codes work: the pattern itself does not tell you whether the destination is trustworthy. A QR code can contain a link just as text can. Before entering passwords or payment details, check where the code is taking you and whether the destination makes sense.
Born in a car parts factory
QR codes were invented in Japan in 1994 by a team at Denso Wave, a company in the Toyota group, led by the engineer Masahiro Hara. The goal was practical: factories tracking car parts needed labels that held more information than ordinary barcodes and could be read quickly from any angle. Workers were scanning many barcodes per box, and a single compact code that a machine could read fast would save time on busy production lines. That origin explains the name Quick Response, and why fast, reliable reading mattered more than looks.
The finder patterns were designed with care. Each one is built so that a line passing through its centre in any direction crosses dark and light sections in a ratio of 1 to 1 to 3 to 1 to 1. The team chose this ratio after studying printed material and finding that the pattern rarely appeared by accident in text and pictures, which made false detections unlikely. Denso Wave held a patent on the technology but chose not to enforce it for the published standard, so anyone could create and read QR codes freely. That openness helped them spread far beyond factories to tickets, menus and payments.
Sizes, recovery levels and the maths of repair
QR codes come in 40 sizes, called versions. Version 1 is a grid of 21 by 21 modules, and each version adds four modules to each side, up to 177 by 177 for version 40. Within any size, the creator also picks one of four error-correction levels, labelled L, M, Q and H, which can restore roughly 7, 15, 25 and 30 percent of damaged codewords respectively. The trade-off is space. The more of the grid devoted to recovery data, the less is left for the message, so a higher level forces either a shorter message or a larger, denser code.
The repair work uses Reed-Solomon codes, a mathematical method published by Irving Reed and Gustave Solomon in 1960. It treats blocks of data as values of a polynomial and adds extra values calculated from them, so missing pieces can be worked out, rather as you can redraw a straight line from any two of its points. The same family of codes protects music on CDs and data sent back from distant spacecraft. QR codes with a logo printed in the middle usually rely on level H, deliberately giving up some capacity so that the decoder can treat the covered modules as damage and still recover the message.
Why some codes are smaller than others
QR codes save space by choosing an efficient encoding mode for the characters being stored. In numeric mode, digits are packed in groups of three, and since three digits have only 1,000 possible values, each group fits into 10 bits. Alphanumeric mode covers 45 characters: the digits, capital letters, the space and a few symbols such as the colon, full stop and slash. Pairs of these characters fit into 11 bits. Byte mode, which handles lower-case letters and most other text, needs 8 bits for every character. So a 12-digit number takes 40 bits in numeric mode but 96 bits in byte mode.
This explains a useful trick. Web addresses are usually written in lower case, which forces byte mode, but the scheme and domain of a web address are not case-sensitive, so a short link written entirely in capitals, such as HTTPS://EXAMPLE.COM, can use the more compact alphanumeric mode. Paths after the domain may be case-sensitive, so this works only when the website accepts capitals. A shorter string of bits can fit into a smaller version, so each module can be printed larger, making the code easier to scan from a distance. At the largest size and lowest recovery level, a code holds up to 7,089 digits but only 2,953 bytes.
The takeaway
QR codes combine a structured two-dimensional grid, encoded data, orientation markers, masking, and error correction. Your camera finds the pattern, software straightens and reads it, and the decoder rebuilds the stored information. Once you know the grid has different jobs, a QR code looks less like noise and more like a compact map.