Bhinish Dhiman

How big does a QR code need to be to scan? Quiet zone, module size and contrast measured

In our tests a QR code scanned once each module covered 2.5 camera pixels, and failed at 2.0 or fewer for levels L and M. A border of 1 module worked, but 0 modules failed every attempt, and the standard asks for 4. A light grey at 28% relative contrast still decoded; 15% did not. These are zxing-cpp results, so treat them as an upper bound.

Ask how small a QR code can be printed and you will get a rule of thumb. We measured three of the things behind it: the empty border, the number of camera pixels per module, and the contrast between the modules and the paper.

The three settings that decide whether it scans

The quiet zone is the empty margin around a QR code, measured in modules. ISO/IEC 18004 clause 5.3.8 requires 4 modules on all four sides, and Denso Wave, who invented the code, says the same: a four-module margin at all sides of a symbol. It is part of the symbol, not decoration.

A module is one square of the grid. The standard fixes no minimum size for it, because clause 5.1 notes that module dimensions are user-specific so the code can be made by many printing methods. So the question of the smallest print size has no answer in the spec. It has a measurable one.

What we measured

Every figure below came from decoding a camera-degraded image: the symbol downsampled to a set number of pixels per module, blurred by 0.8 px, given Gaussian noise at sigma 6 and compressed as a JPEG at quality 70. The decoder was zxing-cpp and the encoder was segno 1.6.6.

Setting Result
Pixels per module, level L, version 3 (29 modules) 0% at 2.0 px, 100% at 2.5 px
Pixels per module, level M, version 4 (33 modules) 0% at 2.0 px, 100% at 2.5 px
Pixels per module, level Q, version 5 (37 modules) 7% at 2.0 px, 100% at 2.5 px
Pixels per module, level H, version 6 (41 modules) 47% at 2.0 px, 100% at 2.5 px
Quiet zone of 4, 3, 2 or 1 modules 100% at every resolution from 2.5 to 10 px
Quiet zone of 0 modules 0% at every resolution
Contrast, relative contrast of 28.4% 100%
Contrast, relative contrast of 14.7% 0%

The pixel threshold is sharp. At 1.75 px and below, every level scored 0%, and at 2.5 px every level scored 100%. Higher error-correction levels hold on slightly longer below the threshold, but none of them removes it.

Why the border fails all at once

The quiet zone result is the surprising one. That test put a version-4, level-M code on solid black. With 1 module of margin it decoded every time; with none it never did, at any resolution up to 10 px per module. A scanner finds the three corner squares first, and without a margin it cannot tell where the symbol ends and the surroundings begin. Error correction never runs, because detection has already failed.

So the decoder tolerated a margin a quarter of the size the standard asks for. We would not build on that. Supermarket scanners and older Android phones are not zxing-cpp, and trimming and bleed on a print job eat into the margin. The tool’s Quiet zone slider runs from 0 to 8 modules; leave it at 4.

Contrast is a luminance question

We measure contrast as the reflectance gap between the lightest and darkest parts, as a share of the lightest: (Rmax - Rmin) / Rmax. We call it relative contrast. Print-verification standards such as ISO/IEC 15415 define their own symbol-contrast grading, and we have not checked this formula against that text, so the figures below are not verifier grades. On a white background the two approaches agree.

Modules on white WCAG ratio Relative contrast Decoded
#666666 5.74:1 86.7% 100%
#999999 2.85:1 68.1% 100%
#bbbbbb 1.92:1 50.3% 100%
#dcdcdc 1.37:1 28.4% 100%
Green #16a34a on red #ef4444 1.14:1 14.7% 0%

The decoder accepted a code at 28% relative contrast. Colour pairs behave the same way, since only luminance counts. That is the subject of how much of a QR code a logo can cover, which also covers the 10:1 distance rule, so we will not repeat it here.

Turning pixels per module into millimetres

The 2.5 px threshold is in camera pixels, so a print size needs arithmetic. The tool uses a pinhole model: module size in mm times the camera’s horizontal pixels, divided by 2 x 2.5 x tan(half the field of view). Its “Phone, camera preview (realistic)” setting assumes 1,920 pixels across and a 65 degree field of view, so tan(32.5 degrees) is 0.637.

For a version-4 code (33 modules) printed 25 mm wide:

  • Module size is 25 / 33 = 0.76 mm.
  • Maximum distance is 0.76 x 1,920 / (2 x 2.5 x 0.637), about 457 mm.
  • On the “full capture in good light (best case)” setting, 4,000 pixels gives about 951 mm.

Run it backwards for a code read from 300 mm on the preview setting. The module must be 300 x 2 x 2.5 x 0.637 / 1,920, about 0.50 mm, so a 33-module code needs to be at least 16.4 mm wide. These are results of the model, not tests with a printed sample, and they assume a flat, sharp print in good light.

The module count matters as much as the width. A version-2 code has 25 modules and a version-10 code has 57, so at one printed width the modules differ by 57 / 25 = 2.28 times, and the version-10 code must be read from that much closer.

What goes wrong

  • No border on a dark surface. Dark mode screens and coloured packaging put a 0-module margin on every side. We saw 0 successes from 5 resolutions of 10 noise seeds each.
  • A small print of a long payload. A longer URL raises the version, adds modules and shrinks each one. Going from 29 to 41 modules at one width shrinks the module by 29 / 41, to about 71% of its size.
  • A light module colour. One pair at 14.7% relative contrast failed outright, while 28% decoded. In poor light you want far more than the minimum.
  • Reading the pass as safe. The threshold is a cliff: 100% at 2.5 px and 0% at 2.0 px for levels L and M. A code that scans on your phone may sit one module of blur from failing on another.

Other ways to do it

There is no built-in method on macOS, Windows, iPhone or iPad for sizing a QR code against a scan distance. Printing a test sheet at the intended size and scanning it from the real distance on a spare phone is the only independent check. For print runs, a barcode verifier grades symbol contrast under ISO/IEC 15415, which is a separate measurement from ours.

Check that nothing was uploaded

Open your browser’s developer tools, choose the Network tab, change the printed width or the quiet zone, and watch the list. Nothing is sent. The code and every readout are calculated in the page.

Caveat

Every decode here used zxing-cpp. It is more tolerant than ISO/IEC 15415 and possibly more tolerant than the median phone, so these are upper bounds. We have not yet re-run them against the iOS camera or ML Kit. Print a test before a long run.

Set the width, the quiet zone and the reading device in the QR code generator, and read the “Scans from” figure under “Will it scan”. For the logo side of the same question, see how much of a QR code a logo can cover. For the same colour logic applied to text, see why WCAG ratios mislead in dark mode.