Guide

QR code error correction, explained

Error correction is repair data stored inside every QR code. If part of the code is dirty, torn or covered, the scanner rebuilds the missing pieces from it. There are four levels: L restores about 7% of the data, M about 15%, Q about 25% and H about 30%. Higher levels survive more damage but make the code denser.

What the percentage measures

The four levels come from the QR code standard, ISO/IEC 18004, and from Denso Wave, the company that invented the code. The repair data is calculated with Reed–Solomon codes, the same family used on CDs.

The percentage counts codewords, the 8-bit chunks the message is split into. It isn't a share of the printed picture. That distinction is where most advice online goes wrong: "level H means you can cover 30% of the code" reads as if any 30% of the area will do. It won't.

A codeword is spread over a small block of modules (the code's little squares). A smudge rarely lines up with whole codewords, so it damages a few modules in many of them, and a codeword with one wrong module counts as fully wrong.

What we measured

We made https://example.com/menu/today (30 characters) at each level with our own encoder, blanked a growing square in the middle, and decoded each image with jsQR, the open-source decoder behind our online scanner. The table shows the largest blank square that still decoded.

LevelGridLargest blank centre that decodedShare of the code's area
L25 × 255 × 5 modules4%
M29 × 297 × 7 modules6%
Q29 × 2910 × 10 modules12%
H33 × 3313 × 13 modules16%

A longer, 90-character link did a little better at level H (a 24 × 24 hole in a 53 × 53 code, about 20%), but nowhere near 30%. These were clean digital images. A phone photo adds blur, glare and angle, so real-world headroom is smaller still.

The cost is a denser code

Repair data takes space, so a higher level needs a bigger grid for the same message. Here is the 30-character link again:

LevelVersion our encoder pickedGrid
L225 × 25
M329 × 29
Q329 × 29
H433 × 33

Printed 3 cm wide, the level L code has modules about 1.2 mm across and the level H code about 0.9 mm. Smaller modules need a closer, steadier camera, which is why "always use H" is bad advice. The versions and capacity page has the full table.

Which level to pick

Use M. Denso Wave says it's the level "most frequently selected", and it's the one our generator uses. Move up to Q or H only for codes that will get dirty or scuffed: factory labels, outdoor signs, packaging that gets handled. Use L only when a code holds a lot of data and lives somewhere clean, like a screen.

Use H whenever a logo covers the middle. Our generator switches to H automatically the moment you add one, and QR codes with a logo explains how big that logo can be.

Our generator has no level switch yet. If you need Q or H on a code without a logo, use a tool that exposes the setting.

What it can't repair

  • The corner squares. When we blanked the top-right finder square of the level H code above, jsQR couldn't find the code at all. Error correction never gets a chance to run.
  • The blank margin. The quiet zone isn't data, so there's nothing to rebuild.
  • Weak contrast. If the camera can't tell dark from light anywhere, no module is readable. The contrast checker tests a color pair in seconds.
  • Modules printed too small. More repair data makes them smaller, not bigger. The QR code size guide works out the width for your scanning distance.

The level is stored in the code's format information, next to the corner squares, so a scanner knows which level it's reading before it decodes anything. Our interactive explainer lets you damage a code yourself and watch the repair happen.

Written by Last updated