How QR codes work
Every part of a QR code has a job. The corner squares orient it, hidden patterns keep the grid aligned, masking makes it readable, and mathematical redundancy lets it survive damage. Here's the full anatomy, decoded.
The big picture
A QR code is a square grid of modules — the small black and white cells. Some modules carry your data; many others are function patterns that exist purely so a scanner can find, orient, and decode the grid reliably. Understanding which is which explains nearly every practical rule, from why codes need a margin to why adding a logo is risky.
The grid size is described by version: version 1 is 21×21 modules, and each step up adds 4 modules per side, to version 40 at 177×177. Higher versions hold more data — see what is a QR code for capacity figures.
Finder patterns
The three large concentric squares in the top-left, top-right, and bottom-left corners are finder patterns. Their distinctive 1:1:3:1:1 ratio of dark-to-light bands is rare in natural images, so a scanner can spot them instantly and from any rotation. Three corners (not four) let the decoder work out the code's orientation — it knows which way is up. A thin separator of light modules rings each finder to keep it distinct from the data.
Timing and alignment patterns
Running between the finder patterns are the timing patterns: a single row and a single column of alternating dark/light modules. They act like a ruler, letting the scanner count module positions precisely even if the image is slightly warped.
Alignment patterns — smaller concentric squares — appear in version 2 and above, increasing in number as the code grows. They help the decoder correct for perspective distortion when a code is photographed at an angle or printed on a curved surface. A version 1 code has none; large codes have many.
Format and version information
Bands of modules beside the finder patterns store format information: which error-correction level was used and which mask pattern was applied. This data is itself protected and repeated so the scanner can read it even if part is damaged. Codes of version 7 and higher add separate version information blocks so large grids are identified correctly.
Data modules
Everything left over holds the encoded message, placed in a zig-zag pattern winding up and down the columns from the bottom-right. Before encoding, your text is converted using the most efficient mode for its characters — numeric, alphanumeric, byte, or kanji — then split into data codewords and error-correction codewords. The more data, the higher the version needed, and the finer the modules become.
QR codes require a clear margin — the quiet zone, ideally four modules wide — around the whole grid. Without it, a scanner can't tell where the code ends and the background begins. It's part of the spec, not decoration.
Masking
If the data modules happened to form large blank areas or patterns that mimic the finder squares, scanning would suffer. To prevent this, the encoder applies a mask — one of eight predefined patterns that flips certain modules in a regular way to balance dark and light and break up problem regions. The encoder tests all eight, scores each for readability, and picks the best. The chosen mask is recorded in the format information so the decoder can reverse it. This is why two codes for the same text can look different.
Error correction
QR codes use Reed-Solomon error correction, the same family of math used on CDs and in deep-space transmission. Extra codewords are added so the original data can be reconstructed even if some modules are unreadable — smudged, torn, or covered by a logo. The four levels recover roughly 7% (L), 15% (M), 25% (Q), or 30% (H) of the codewords. Higher recovery means more redundancy, a denser code, and more resilience. The full trade-off is in error correction levels.
Watch the anatomy change live
Type into the generator and see the version, module count, and structure update in real time as your data grows.
Open the generatorFrequently asked questions
What are the three squares in the corners?
They're finder patterns. Their distinctive band ratio lets a scanner locate the code instantly and, because there are three, work out its orientation.
Why do two QR codes for the same text look different?
Because of masking. The encoder tests eight mask patterns and picks the one that makes the most readable code, so the same text can produce different-looking grids.
What is the quiet zone?
The clear margin around the code, ideally four modules wide. It lets a scanner separate the code from its background and is required by the standard.
How can a damaged QR code still scan?
Reed-Solomon error correction adds redundant data so the original message can be rebuilt even when some modules are unreadable — up to about 30% at the highest level.