A QR code's version (1 to 40) corresponds one to one with the number of modules along one side, which means you can determine it by counting. This article covers practical ways to count even a fine-grained symbol, and how to read the version information written into codes from version 7 upward.
The version follows from the module count
A QR code's version runs from 1 to 40 and defines how much data the symbol can hold. The version and the number of modules per side correspond one to one:
modules per side = 4 × version + 17
Which means that if you can count the modules, you can compute the version:
version = (modules per side - 17) ÷ 4
Version 1 is 21x21 and version 40 is 177x177. The module count is always an odd number starting at 21 and increasing in steps of 4 (21, 25, 29, 33, and so on), so a count that does not fit that sequence means either a miscount or that the symbol is not a QR code at all.
Check the version against the module count
Move the slider to pick a version, or type a module count into the field, and the corresponding values are computed on the spot. No network connection is required.
How to count: use the timing pattern
Counting a fine grid one module at a time is not practical. In the field, this sequence is reliable.
- Use a finder pattern as a ruler. The large corner squares are always 7 modules across. Measure that width first to establish the size of one module.
- Count the timing pattern. Between the top-left and top-right finders runs a line of alternating dark and light modules (the seventh row from the top, row 6 counting from zero). Alternating runs are easy to count, so count that and derive the rest.
- Add it up. One side consists of the left finder (7) plus a separator (1) plus the timing section plus a separator (1) plus the right finder (7). So if the alternating section is M modules long, the side is M + 16 modules.
For example, an alternating section of 29 gives a side of 45 modules, and a version of (45 - 17) ÷ 4 = 7.
Alignment patterns give you a quick estimate
If you want to narrow the version down before counting, the number of alignment patterns (the small 5x5 concentric squares) is a good indicator. The count is fixed per version and steps up every seven versions.
| Version | Modules per side | Alignment patterns |
|---|---|---|
| 1 | 21 | 0 |
| 2 to 6 | 25 to 41 | 1 |
| 7 to 13 | 45 to 69 | 6 |
| 14 to 20 | 73 to 97 | 13 |
| 21 to 27 | 101 to 125 | 22 |
| 28 to 34 | 129 to 153 | 33 |
| 35 to 40 | 157 to 177 | 46 |
No alignment pattern at all means version 1 for certain; a single one near the centre means version 2 to 6, and so on. The rule behind the counts is that when there are n candidate centre coordinates, patterns go at the n by n intersections minus the three that would collide with finder patterns, giving n² - 3.
Version 7 and above carry version information
From version 7 upward, the version number itself is written into the symbol, in a field called the version information. Versions 6 and below omit it, because counting the timing pattern is enough to tell them apart.
The version information is 18 bits:
- 6 bits: the version number (7 to 40 in binary)
- 12 bits: error correction bits protecting it (a BCH(18,6) code)
Unlike the format information, no XOR mask is applied to the version information. The first six bits are therefore the version number in plain binary. Version 7 begins with 000111 (which is 7) and the full 18 bits are 000111110010010100. Version 40 begins with 101000 (which is 40) and the full string is 101000110001101001.
The version information is also placed twice: once to the left of the top-right finder pattern (6 rows by 3 columns) and once above the bottom-left finder pattern (3 rows by 6 columns). Being BCH-protected, it survives a certain amount of damage.
Practical cautions when counting from an image
- Check the margin first. Make sure the quiet zone (at least 4 modules) is included in the shot, and take care not to count the margin as part of the symbol.
- Watch for bleeding. In a photo of printed material, adjacent dark modules may appear merged. Zoom into the alternating section of the timing pattern until individual modules separate, then count.
- Verify your count. If (module count - 17) is not divisible by 4, you miscounted. Adjust to the nearest value that is divisible by 4.
- Structured append is different. When data is split across several QR codes, each symbol has its own version.
What the version tells you
Once the version is fixed, so is the upper bound on how much data the symbol can hold. The actual capacity also depends on the error correction level and the encoding mode (numeric, alphanumeric, 8-bit byte, kanji), so read it together with a capacity table. QR Code Specifications and How They Work covers that in detail.
A higher version, meaning a finer grid, also demands more of your printing and camera resolution. If codes are failing to scan, it is worth asking whether the version can be lowered by shortening the data. Cause-by-cause fixes are in Why Your QR Code Won't Scan and How to Fix It.
Summary
- Modules per side = 4 x version + 17, so the version follows from the count.
- To count, measure the alternating section of the timing pattern and add 16 to get the side length.
- The number of alignment patterns narrows the version to a range at a glance.
- Version 7 and above carry 18-bit version information with no XOR mask, whose first six bits are the version number itself.
- Check your count by confirming that (module count - 17) is divisible by 4.
Frequently Asked Questions
How do I find out a QR code's version?
Count the modules along one side and compute (module count - 17) divided by 4. The number of modules per side is 4 times the version plus 17, so version 1 is 21x21 and version 40 is 177x177.
Is there a trick to counting the modules of a fine-grained QR code?
Use the timing pattern. Count the run of alternating dark and light modules between the top-left and top-right finder patterns and add 16 to get the number of modules per side. The fact that a finder pattern is always 7 modules across is also useful as a ruler.
Can the number of alignment patterns tell me the version?
It gives you a range. Version 1 has none, versions 2 to 6 have one, 7 to 13 have six, 14 to 20 have thirteen, 21 to 27 have twenty-two, 28 to 34 have thirty-three and 35 to 40 have forty-six. If there are none at all, the version is definitely 1.
What is the version information?
It is an 18-bit field written into QR codes from version 7 upward, made up of six bits of version number and twelve error correction bits of a BCH(18,6) code. Unlike the format information it is not XOR masked, so the first six bits are the version number in plain binary. It appears in two places: to the left of the top-right finder and above the bottom-left finder.