QR Code Best Practices: Size, Contrast, Error Correction and Testing

5 min read · Published 1 November 2026 · Updated 2 November 2026

A QR code that will not scan wastes the effort of printing it. Most failures come from a few avoidable problems: too much data, low contrast, a missing margin or a code printed too small. This guide explains how a QR code stores information and the practical rules that make it scan on the first try, on any phone.

How a QR code stores data

A QR code is a square grid of dark and light modules (the small squares). The three large squares in the corners let a scanner find the code and its orientation. The data is protected by error correction (Reed–Solomon codes), which lets the code still be read when part of it is dirty, damaged or covered. There are 40 sizes (versions), from 21×21 modules up to 177×177, and the more text you encode, the denser and larger the grid becomes.

Error correction levels

You choose how much of the code can be lost and still be recoverable. Higher levels are more robust but add more modules, making the code denser:

  • L (low): recovers about 7% of the code.
  • M (medium): about 15%. A good default for most uses.
  • Q (quartile): about 25%.
  • H (high): about 30%. Use it when a logo will cover the centre or the code may be scratched or printed on rough surfaces.

Keep the content short

A shorter URL makes a simpler, bigger-module code that scans faster from farther away. Remove tracking parameters you do not need, prefer a short path on your own domain and use https. A very long link produces a dense code that cheap cameras struggle with.

Contrast and colours

  • Use dark modules on a light background. Black on white is the most reliable.
  • Avoid light-on-dark (inverted) codes unless you have tested them. Some scanners cannot read them.
  • Coloured codes are fine when the contrast is strong. Two similar mid-tones are not.

The quiet zone

Leave an empty margin around the code, at least four modules wide. Text, borders or images touching the code confuse the scanner. When you place a QR code on a coloured background, put it on a white block with that margin.

Size and distance

As a rule of thumb, the scanning distance should be no more than about ten times the width of the code. A code 2 cm wide scans comfortably from about 20 cm, which suits a business card. A poster viewed from 3 metres needs a code at least 30 cm wide. As a general minimum, avoid printing codes smaller than about 2 × 2 cm.

A logo in the middle hides modules, so use error correction level Q or H, keep the logo small (well under a quarter of the code area) and test with several phones. If a code has to be perfectly reliable, skip the logo.

PNG or SVG?

PNG is a pixel image that suits screens and documents, but it blurs if scaled up. SVG is a vector format that stays sharp at any size, so it is the better choice for print, signage and packaging. Whichever you choose, export it at a size that is a whole multiple of the module size to avoid blurry edges.

What you can encode

  • A web link (URL) or plain text.
  • A Wi-Fi login in the format WIFI:T:WPA;S:NetworkName;P:Password;;
  • A phone number (tel:+84...), an email (mailto:), an SMS or contact details (vCard).

Test and stay safe

  1. Scan the code with at least two different phones (one older) and with the built-in camera app, not only a dedicated scanner.
  2. Test at the real size and distance, on the real material, in typical lighting.
  3. Check that the link opens the right page over a mobile connection.
  4. As a user, remember that a QR code can hide a malicious link. Look at the address your phone shows before you open it, especially on stickers placed over other codes.

Versions and how much data fits

QR codes come in 40 versions. Version 1 is 21 × 21 modules, and each version adds four modules per side, so the size is 17 + 4 × version. The largest, version 40, is 177 × 177 modules. At the lowest error correction level (L), version 40 can hold up to 7,089 digits, 4,296 alphanumeric characters or 2,953 bytes. Higher error correction levels reduce these numbers, and every extra character makes the code denser, so shorter content scans more easily.

Static and dynamic QR codes

A static code stores the content itself, such as the full URL. It never expires, needs no account and cannot be changed after printing. A dynamic code stores a short link to a redirect service, which can then point to any address you choose later and can count scans. The trade-off is that a dynamic code works only as long as the service and its link keep working, so printing one on something permanent depends on a third party.

Frequently asked questions

Do QR codes expire?
A static code never expires, because it holds the content directly. A dynamic code stops working if the redirect service is shut down or the subscription ends.
Why does my code not scan when printed small?
Usually the modules are too small for the camera to separate, often because the code holds a long link. Shorten the link, enlarge the code, increase the contrast and keep the quiet zone clear.
Can I scan a QR code from a screen?
Yes, if the screen is bright, the code is large enough and there is no glare. Codes shown on screens are best exported as PNG at a size that is a whole multiple of the module size.
Is scanning a QR code safe?
Scanning itself is safe, but the content may lead to a harmful page. Check the address your phone shows before you open it, and be careful with codes on stickers placed over other codes.

Sources and further reading

Try it yourself: QR Code Generator runs in your browser, free and with no sign-up.

More guides