How a QR Code works: the anatomy behind the squares
Date Published
Everyone uses QR Codes and almost nobody knows what they are looking at. That tangle of squares is not random: every region has a specific job, and understanding the structure explains directly why one code fails to scan, why another comes out too dense, and why you can paste a logo in the middle without breaking everything.
The core idea: it is just drawn text
A QR Code stores no files, connects to nothing and does nothing on its own. It stores text. When that text starts with "https://", the phone understands it is an address and offers to open the browser. When it starts with "WIFI:", it understands they are network credentials. When it is ordinary text, it shows the text on screen.
All the intelligence lives in the reader, not in the code. The code is paper — well organised, but paper.
- Position patterns
- locate and orient the code
- Alignment
- corrects distortion
- Timing
- delimits each module
- Quiet zone
- 4-module clear margin
- Data + error correction
The three big squares: position patterns
Those three squares in the top-left, top-right and bottom-left corners are the position detection patterns. They are the first thing a reader looks for.
Their proportions are deliberate: scanning a straight line through any of them, at any angle, always yields the sequence black-white-black-white-black in a 1:1:3:1:1 ratio. That signature is rare in natural images, which lets the software locate the code instantly inside a photo full of other things.
Because there are three and not four, the reader also works out the orientation: the corner without a square is the bottom-right one. That is why a QR Code scans upside down, sideways or crooked — the software corrects the rotation by itself.
The other structural elements
- Alignment patterns — the smaller squares scattered through the code. They correct distortion when the code sits on a curved surface or is photographed at an angle. Very small codes have none; large ones have several.
- Timing patterns — the alternating black and white rows connecting the position squares. They act as a ruler, telling the reader where one module ends and the next begins.
- Format information — the band around the position squares. It stores which error correction level was used and which mask was applied.
- Quiet zone — the white margin around everything. It is not decoration: the specification requires the equivalent of 4 clear modules. Invading that margin is one of the most common causes of scan failure.
Modules and versions: why some codes are dense
Each individual square is called a module. The grid size is set by the version of the code, which runs from 1 to 40:
- Version 1: a 21 × 21 module grid, holding about 25 characters.
- Version 10: a 57 × 57 grid, about 270 characters.
- Version 40: a 177 × 177 grid, up to 4,296 alphanumeric characters.
Here is the practical point: more content means more modules in the same physical space. A version 40 code printed at 3 cm has modules smaller than 0.2 mm — smaller than many printers can reproduce sharply and than many cameras can distinguish.
That is why a phone QR Code scans easily from a distance while a contact QR Code packed with fields fails on the same card. It is not generator quality: it is quantity of information.
Error correction: why the logo in the middle works
QR Codes use a correction algorithm called Reed-Solomon, the same kind of mathematics that lets a scratched CD keep playing. The information is stored with redundancy, so part of the code can be destroyed and the reader still reconstructs the original content.
There are four levels:
- L (Low) — recovers about 7% damage. Produces the cleanest code.
- M (Medium) — about 15%. The default in most generators.
- Q (Quartile) — about 25%.
- H (High) — about 30%. Produces the densest code.
It is precisely this redundancy that allows a logo in the centre: you are deliberately destroying part of the code and relying on correction to compensate. That is why every serious generator applies level H when there is a logo — and why there is a limit. Covering more than 30% of the area exceeds the recovery capacity and the code dies.
The trade-off is direct: the higher the correction, the more space goes to redundancy and the less remains for content, which increases density. High correction on a large vCard is the combination that most often produces an unreadable code.
What this changes in practice
- Shorten the content whenever possible — it is the only way to genuinely reduce density.
- Respect the white margin. It is part of the code, not leftover layout.
- If you use a logo, keep it small and centred, and test on two devices.
- Size the print with the 10-to-1 rule: the side of the code should be at least a tenth of the scanning distance.
Want to watch density change in practice? Open the text generator and keep adding sentences: the code visibly gains modules at every version jump.