QR codes explained: capacity, error correction and print size

Updated:

A QR code is a grid of black and white squares that stores text: usually a link, sometimes a Wi-Fi login, a phone number or a payment request. It was announced in 1994 by Denso Wave, then a division of the car-parts maker Denso, to track components through its factories, and became universal once phone cameras learned to read it. The same code can be read even when part of it is dirty or covered, and the amount it holds depends on three choices: how much text, what kind of text, and how much damage it must survive. This guide covers those choices and what they mean for a code you are about to print.

What is in the grid

Each square is a module. The three large squares in the corners are finder patterns: they tell the reader where the code is and which way up it is. Lines of alternating modules between them, the timing patterns, give the grid spacing, and from version 2 onwards smaller alignment squares help correct for a curved or tilted surface. A strip next to the finders records the error correction level and the mask, one of 8 patterns laid over the data so that it never forms large blank areas or shapes that look like a finder. Codes of version 7 or higher also record their version. Everything else is data and error correction.

Around the code there must be an empty margin, the quiet zone, four modules wide on every side. Without it the reader may not find where the code ends, and a code that looks perfect on screen can fail once it is printed against a busy background.

Versions: why some codes are denser

The size of the grid is called the version. Version 1 is 21 × 21 modules, and each version adds 4 modules to each side, up to version 40 at 177 × 177. A generator picks the smallest version that fits the text, so more text means more, smaller modules in the same printed area. These are the versions some typical contents need at level M, the most common choice:

ContentCharactersVersion at level M
https://ntools.xyz182 (25 × 25)
A Wi-Fi login with a 28-character password584 (33 × 33)
A long link with five tracking parameters1268 (49 × 49)

The long link needs almost twice as many modules per side as the short one. Printed at the same size, each of its modules is just over half as wide, so the phone has to be closer and steadier. Shortening the link is the most effective way to make a code easier to scan.

How much a QR code can hold

A QR code encodes text in one of four modes. Numeric mode packs digits most tightly. Alphanumeric mode covers 45 characters: the digits, the capital letters A to Z, space and $ % * + - . / :. Byte mode takes any data, and is what almost every link uses, because lower-case letters are not in the alphanumeric set. Kanji mode is for Japanese text.

The standard's default character set for byte mode is ISO 8859-1, which covers Western European letters only. Text in other alphabets, or with symbols such as €, is written as UTF-8 by most generators, nTools included, and the reader has to recognise it, which many readers do but not all. The largest code, version 40, holds:

LevelDigitsAlphanumericBytes
L7,0894,2962,953
M5,5963,3912,331
Q3,9932,4201,663
H3,0571,8521,273

Those are limits, not targets. A version 40 code has 31,329 modules, and a phone can only read it when it is printed large and sharp. For anything printed, short content keeps the code easy to read.

QR & Wi-Fi QR generator

Error correction: L, M, Q and H

QR codes use Reed–Solomon error correction, the same family of codes used on CDs. Part of every code is redundant data from which the reader can rebuild what is missing. There are four levels, and each one can restore about this much of the data:

Denso Wave notes that level M is the one most often chosen, with Q or H for dirty environments such as factories and L for clean conditions and large amounts of data. The cost of a higher level is size: the same link at level H needs more modules than at level M. The percentages count codewords, blocks of 8 bits, not modules, so a scratch across the code can spoil more of it than its area suggests.

A logo in the middle of a code works only because error correction rebuilds the modules it hides, so it spends part of that margin before the code has any dirt or glare to deal with. If you add one, keep it small, never cover the three corner squares or the quiet zone, and test the result on several phones.

How big to print it

The printed size is the number of modules, plus 8 for the quiet zone, multiplied by the width of one module. Denso Wave's own example is a version 3 code, 29 modules wide, printed with 0.254 mm modules: 7.4 mm for the code and 9.4 mm with its margin. Modules that small suit a dedicated scanner held close to the label; a phone camera at arm's length needs much larger ones.

At a printed width of 2 cm including the margin, a version 2 code has modules about 0.61 mm wide, while a version 8 code has modules of about 0.35 mm. If a code has to be small, keep its content short.

Wi-Fi QR codes

A Wi-Fi code is plain text in a format that phone cameras recognise. It was popularised by the ZXing barcode project and is not part of the QR standard itself:

The characters \ ; , : and " are escaped with a backslash inside the name or the password; the nTools generator does this for you.

The password is stored in the code as readable text: anyone who scans the code, or photographs it, has the password. For a code on a wall, use a guest network.

Static and dynamic codes

A static code contains the content itself, such as the link or the Wi-Fi login. It never expires, has no scan limit and works without any service in between; to change the content, you print a new code. The nTools generator creates static codes.

A dynamic code, sold by many QR services, contains a short link to that service, which then redirects to your real address. You can change the destination later and count scans, but every scan depends on the service: if the subscription ends or the company closes, the printed codes stop working.

Scanning safely

A QR code cannot run anything by itself; it only hands the phone some text, usually a link. The risk is where that link goes. The US Federal Trade Commission warns about fake codes stuck over real ones, for example on parking meters, and about codes in unexpected messages that urge you to act immediately.

Frequently asked questions

Do QR codes expire?

A static code never expires: it contains the content itself. A dynamic code stops working when the service behind its short link stops redirecting it.

Why won't my QR code scan?

The usual causes are a code printed too small for the amount of content, a missing or cluttered quiet zone, low contrast, glare or a crease, or a logo that covers too much. Shortening the content makes every module larger.

Which error correction level should I use?

Level M suits most printed codes. Use Q or H if the code will get dirty or worn, or carries a logo, and accept that it will be denser.

What does the nTools generator do?

It creates static codes at level M, choosing the smallest version that fits, and adds the four-module quiet zone. The code is drawn in your browser and nothing you type is uploaded.

Related guides