Appearance
Tech

How Damaged Can a QR Code Be and Still Scan? Error Correction Explained

Published

Depending on the level you choose, a QR code still scans with about 7% (L), 15% (M), 25% (Q) or 30% (H) of it damaged. That works because Reed-Solomon recovery bytes are appended to the data; in the smallest QR code, level H spends 17 of 26 bytes on recovery. Cover one of the three big corner squares, though, and it fails no matter the level.

The QR sticker on a café table usually still scans after it gets scratched or stained with coffee, and plenty of QR codes have a logo sitting right in the middle. The reason a code can lose some of its squares and still give back the original content is error correction. This post covers how much damage a QR code survives, where those numbers come from, and which level to choose when you make one.

Four levels: L, M, Q and H

When you create a QR code you pick one of four error correction levels. The standard's approximate recovery figures are:

LevelDamage it can recoverRecovery bytes in version 1Bytes it can fix in version 1
Labout 7%72 (7.7%)
Mabout 15%104 (15.4%)
Qabout 25%136 (23.1%)
Habout 30%178 (30.8%)

The smallest QR code (version 1, 21×21 modules) holds 26 bytes in total. At L, 19 of them carry content and 7 are for recovery; at H only 9 carry content and the other 17 are for recovery. That is why higher levels are sturdier but hold less. These numbers come straight from the table in the library the QR Code Generator uses.

The gap widens in larger codes. In this site's generator, letters and digits fit up to 2,953 characters at L, 2,331 at M, 1,663 at Q and 1,273 at H. Korean text takes 3 bytes per character, so the limits are 984, 777, 554 and 424 characters. The sturdiest level holds less than half of what the weakest one does.

What Reed-Solomon codes do

The recovery bytes are built with Reed-Solomon codes, published by Irving Reed and Gustave Solomon in 1960. The content bytes are treated as coefficients of a polynomial, which is divided by a fixed generator polynomial; the remainder becomes the recovery bytes. The reader repeats the calculation on what it received, and if something does not add up, it works backwards to find which positions are wrong and what their values should be.

The key rule is simple. Two recovery bytes let you fix one wrong byte when you do not know where it is. If you do know where the gaps are, you can fill as many as there are recovery bytes. Version 1 at H uses 17 of 26 bytes (about 65%) for recovery, so it can fix half of that, 8 bytes or about 30%. In small versions, L and M set some recovery bytes aside purely for checking, to avoid "fixing" a code into the wrong content, which is why L appends 7 bytes yet fixes only 2. The standard quotes rough figures of 7, 15, 25 and 30% because the exact ratio varies slightly by version. The same family of codes protects CDs and DVDs from scratches and has carried data back from deep space probes.

The percentage counts bytes, not area

A common misunderstanding: 30% does not mean you can cover 30% of the picture. It means 30% of the bytes may be wrong. Each byte is spread over 8 modules, so a smudge that touches many bytes a little can ruin more bytes than its size suggests. To soften this, QR codes interleave bytes across several blocks, so a torn corner spreads its damage across blocks instead of wiping out one.

Some parts are not covered by error correction at all. The three large corner squares (finder patterns) are how a camera locates the code and works out its orientation; badly cover one and decoding never starts. The format information, which records the error correction level and mask, is written twice so that one copy can be damaged. A white quiet zone of about 4 modules around the code also matters, so the code stands apart from its background.

Which level for a logo?

A logo placed in the middle turns every module beneath it into wrong data. A QR code for this site's address (https://scottools.com) at level H is 29×29, or 841 modules; covering just the central 9×9 removes 81 modules, about 10%. Printing blur and stains can add to that, so if you add a logo, choose H and keep the logo well inside the correction limit.

For screens or clean paper prints, M is enough. Raising the level adds modules for the same content and makes them denser: the same address is 25×25 at L and M but 29×29 at Q and H. On a small sticker of fixed size, bigger modules scan more reliably, so a lower level can actually work better.

The QR Code Generator defaults to M and offers all four levels. It draws the code right in your browser from a link, text or Wi-Fi details and saves it as PNG or SVG. If the code is going outdoors, make it at Q or H and try scanning it with part of it covered by your hand to see how much it tolerates.

Tools in this post

More posts