Skip to content

Making QR codes that actually scan

How QR codes store data, how to choose an error-correction level, and the contrast, margin, size and testing rules that decide whether a printed code works.

Published

A QR code that does not scan is worse than no code at all, because the people who try it assume the fault is theirs. Almost every failure comes from a handful of decisions made before printing: how much data went in, which error-correction level was chosen, the colours, the margin and the printed size. Each of those follows from how the format works, which is worth a few minutes to understand.

How a QR code holds data

A QR code is a square grid of dark and light cells called modules. The format, defined in ISO/IEC 18004, comes in 40 sizes called versions. Version 1 is 21 × 21 modules, and each version adds four modules to each side, so version 2 is 25 × 25 and version 40 is 177 × 177. A generator picks the smallest version that can hold your content at the error-correction level you asked for.

That is the key point: the code grows with the content. The printed square stays the size you make it, so more data means more modules packed into the same space, and each module becomes smaller. Smaller modules are harder for a camera to resolve, especially at a distance, in poor light or on a cheap phone.

How efficiently characters are stored depends on the encoding mode. The standard defines four:

  • Numeric — digits only, the most compact.
  • Alphanumeric — digits, upper-case letters, the space and the symbols $ % * + - . / :.
  • Byte — any byte, typically text as UTF-8. Lower-case letters, ?, = and & all need this mode, so in practice nearly every URL is stored as bytes.
  • Kanji — a compact mode for Japanese characters.

At the largest version and lowest error correction, a code holds 7,089 digits, 4,296 alphanumeric characters or 2,953 bytes. Those maximums are theoretical; a code anywhere near them is a dense texture that few phones will read from a printed page.

Error correction: L, M, Q and H

QR codes use Reed–Solomon error correction, which adds redundant data so the code can still be decoded when part of it is dirty, scratched, creased or covered. You choose how much redundancy to add. The percentages are the approximate share of the data that can be lost and recovered.

LevelRecovers aboutSuits
L (Low)7%Screens and clean, controlled print where size is tight
M (Medium)15%A sensible general default
Q (Quartile)25%Print that will be handled, folded or exposed to dirt
H (High)30%Outdoor signage, curved surfaces, rough environments

The trade-off is that redundancy takes space. A higher level needs more modules for the same content, so it pushes the code up a version or more. Higher is not automatically better: a code at H with small modules can be harder to scan than the same content at M with larger ones. Error correction protects against damage; it does nothing for a code that was printed too small in the first place.

A worked example

Suppose you are printing a poster for an open day. Here are two ways of linking to the same page:

https://example.com/events/2026/spring-open-day?utm_source=poster&utm_medium=print&utm_campaign=open-day
(104 characters)

https://example.com/open-day
(28 characters)

Generated at each error-correction level, the module counts are:

Level104-character URL28-character URL
L37 × 37 (version 5)25 × 25 (version 2)
M41 × 41 (version 6)29 × 29 (version 3)
Q49 × 49 (version 8)29 × 29 (version 3)
H57 × 57 (version 10)33 × 33 (version 4)

Print either one 3 cm wide at level H. The long URL gives modules of about 0.53 mm; the short one gives about 0.91 mm, nearly twice as large. The short code is more forgiving of focus, light and distance, and it still has the higher error-correction level. If the long address matters for analytics, set up a short path on your own site that redirects to it, and encode the short path.

Contrast and colour

Scanners look for a difference in brightness, not in hue. Dark modules on a light background, with a large gap in lightness between the two, is what every reader is built for. Black on white is the safe choice; dark navy on cream works; mid-grey on light grey, or red on green of similar lightness, does not.

Inverted codes — light modules on a dark background — are a common cause of failure. The 2015 edition of the standard permits decoders to handle reversed reflectance, but support varies between apps and devices, so an inverted code that works on your phone may fail on someone else’s. Keep the foreground darker than the background.

The quiet zone

The standard requires a clear margin around the code at least four modules wide on every side, in the background colour. The scanner uses it to find where the code begins. Text, a border or a busy photograph pressed against the pattern is a frequent reason a well-made code refuses to scan.

Because the margin is measured in modules, it scales with the code: a denser code at the same printed size needs less physical margin, a larger print needs more. For the 33 × 33 code in the example, printed 3 cm wide, four modules is about 3.6 mm on each side.

Print size and scanning distance

A rule of thumb used in print and signage, not a figure from the standard, is that a code can be scanned from about ten times its width. A 3 cm code suits something held in the hand; a code meant to be read from 3 m away needs to be in the region of 30 cm across. Treat that ratio as optimistic for dense codes and for poor lighting, and test at the real distance rather than relying on it.

Why shorter URLs are better

Every character in the URL costs space, so the example above is the general case. Drop tracking parameters you do not need, avoid long path segments, and prefer a short path on your own domain. A short link on your own domain also means you control where it goes, which matters for the next point.

Percent-encoding inside the URL

A URL in a QR code must still be a valid URL. Spaces, ampersands inside a value, accented letters and other reserved characters have to be percent-encoded, or the phone opens the wrong address. The URL encoder handles a single value: encode the query value, not the whole URL, then assemble the address around it. Note that each encoded byte becomes three characters, so a non-Latin word can triple or more in length. That is another reason to keep the content of the code as plain as possible.

Static codes cannot be changed or tracked

A QR code is not a link to a service; it is the text itself, drawn as a pattern. Once printed, it points wherever you encoded, permanently. There is no way to edit it, no expiry, and no record of who scanned it.

So-called dynamic codes work by encoding a short address on a redirect service, which can then be changed and which can log scans. That is a trade: the code depends on that service continuing to exist. If you want the flexibility without the dependency, encode a short address on a domain you own and change the redirect on your own server.

Test before you print

  1. Print a proof at the final size, on the final material if possible. A code that scans from a monitor can fail on glossy or textured stock.
  2. Scan it with more than one phone, and with both the built-in camera and another scanning app.
  3. Scan from the distance and angle people will actually use.
  4. Follow the link to the end. Check that the page loads, is not behind a login and works on a phone.
  5. Scan the proof again once it is placed in the final layout, with the surrounding text and imagery in position.

PNG or SVG

SVG is a vector format: the modules are described as shapes, so the code stays perfectly sharp at any size. It is the right choice for anything going to a printer or a design application. PNG is a fixed grid of pixels. It is fine for a web page, a slide or a document, but enlarging it blurs the module edges; if you must use PNG for print, export it large and scale it down, not up.

Using the generator on this site

The QR code generator runs in the page. It accepts up to 500 characters, offers all four error-correction levels (it starts at H), lets you choose foreground and background colours, and downloads PNG or SVG. It does not add a quiet zone to the downloaded image — the file stops at the edge of the pattern — so leave that margin in your layout. It produces static codes only, and does not offer logo overlays.

Tools referred to in this guide