QR code error correction levels explained: L, M, Q and H
A QR code can still scan when part of it is dirty, scratched or covered. That is thanks to error correction. When you generate a code, you usually pick a level, and the choice has real trade-offs. The four leve
A QR code can still scan when part of it is dirty, scratched or covered. That is thanks to error correction. When you generate a code, you usually pick a level, and the choice has real trade-offs.
The four levels
| Level | Approx. damage it can recover from |
|---|---|
| L | about 7% |
| M | about 15% |
| Q | about 25% |
| H | about 30% |
These are the standard figures from the QR specification. The real result depends on where the damage is, not only how much there is.
The trade-off
Higher error correction adds more redundant data to the code. The same content then needs a denser pattern with smaller squares. A dense code is harder to scan at a distance or when it is printed small. So higher is not always better.
Which level to pick
- L or M for a code on a screen, or a large printed code with a short URL. M is a common default.
- Q or H for codes that will get dirty or worn, such as stickers on equipment, outdoor labels or packaging.
- Q or H if you place a logo in the middle. The logo hides part of the code, and the error correction makes up for it. Keep the logo small and test the result.
Keep the content short
A short URL gives a simpler pattern, which leaves room for a higher correction level without making the squares tiny. If a link is long, use a shorter one that redirects to it.
Always test the final print
- Scan the printed code with two different phones.
- Test it from the distance people will actually use.
- Leave a blank margin around the code, about four squares wide.
- Avoid low contrast and glossy surfaces that reflect light.
Disclosure: I work on QRizeo, a free QR code and barcode generator (https://qrizeo.com). The advice above applies to any generator.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.