Spec & internals
Alignment patterns: the small squares that fix distortion
Alignment patterns are 5×5 squares (a dark outline, a light ring and a single dark centre module) that anchor the decoder's sampling grid against perspective and curvature. Version 1 has none, version 2 has one, and the count grows to 46 at version 40, at positions fixed by the standard.
The structure
An alignment pattern is 5 × 5 modules: a dark outline, a 1-module light ring inside it, and a single dark module at the centre. It is a miniature of the finder pattern: small enough to be cheap, distinctive enough to be found once the decoder already knows roughly where to look.
What they are for
The three finder patterns fix the corners, but between the corners the decoder must guess where every module centre sits. On a flat, squarely photographed code, linear interpolation would do. Real scans are not that: camera lenses distort, paper curves, labels wrap around bottles, and phones shoot at an angle.
Alignment patterns are known landmarks scattered across the interior. The decoder predicts where each one should be, finds where it actually is, and warps its sampling grid to match, piecewise, between each set of anchors. The bigger the symbol, the more modules sit between the corners, the more anchors are needed.
How many, and where
The positions come from a table in ISO/IEC 18004 (Annex E). They are not computed by a neat formula, though they are approximately evenly spaced between coordinate 6 and the right edge. The full list is in the alignment pattern position table; the shape of the growth:
| Versions | Centre coordinates per axis | Patterns per symbol |
|---|---|---|
| 1 | n/a | 0 |
| 2–6 | 2 | 1 |
| 7–13 | 3 | 6 |
| 14–20 | 4 | 13 |
| 21–27 | 5 | 22 |
| 28–34 | 6 | 33 |
| 35–40 | 7 | 46 |
The count is the number of coordinate pairs minus three: with k coordinates per axis there are k² grid intersections, but the three that would sit on top of finder patterns are skipped. Version 7, for example, uses coordinates {6, 22, 38} on each axis, nine intersections, minus the three finder corners, gives six patterns. Version 40 uses {6, 30, 58, 86, 114, 142, 170}, 49 intersections, 46 patterns.
Version 1 gets away with none because a 21 × 21 grid is small enough to interpolate from the finders and timing patterns alone.
Why this matters in practice
Alignment patterns are function patterns: not protected by error correction. A logo or styling element that lands on one removes a grid anchor, and the damage is worst on dense codes photographed at an angle, exactly the scans that needed the anchor. Good generators (including UseQR's renderer) treat alignment patterns as keep-clear zones when placing a centre logo, and styles that redraw modules should preserve their solid 5 × 5 geometry.
This is also why very dense codes fail on curved surfaces before sparse ones do: more modules between anchors means each anchor is doing more work. If you control the payload, a shorter one buys a lower version, fewer, better supported modules. Then verify the print.
FAQ
What is the small square inside a QR code?
An alignment pattern: a 5×5 square with a dark centre module that gives the decoder a known landmark for correcting lens distortion, curvature and perspective. Larger QR versions contain more of them, up to 46 at version 40.
Why do some QR codes have no small square?
Version 1 codes (21×21 modules) have no alignment patterns; the symbol is small enough to sample accurately from the finder and timing patterns alone. Every version from 2 upwards has at least one.
Where are alignment patterns placed?
At grid intersections listed in Annex E of ISO/IEC 18004, roughly evenly spaced coordinates on each axis, with the three intersections that would overlap finder patterns omitted. The positions are fixed per version, not chosen by the generator.
Can a logo cover an alignment pattern?
It should not. Alignment patterns are not protected by error correction, and losing one degrades grid calibration, most visibly on dense codes scanned at an angle or on curved surfaces. Keep logos clear of them and verify the result decodes.
Try it: free, no signup
Related
- QR code anatomy: every region of the symbol, A labelled tour of a QR code: finder patterns, separators, timing, alignment, format and version information, the data region and the quiet zone.
- Finder patterns: how a scanner locates a QR code, The three 7×7 corner squares produce a 1:1:3:1:1 dark-light signature on any scan line through their centre, which is what makes QR codes rotation-proof.
- QR code versions 1 to 40: sizes, capacity and how to choose, Versions run from 21×21 to 177×177 modules, growing 4 per step. The right version is the smallest that fits your payload at your error-correction level.
- QR alignment pattern position table: versions 2 to 40, Alignment pattern centre coordinates for QR versions 2–40, with the n² − 3 count rule and why encoders embed this table rather than compute it.