How to Check a QR Code's Error Correction Level

Sometimes you need to know which error correction level a QR code was built with. The level is in fact written into the code as a value, and you can read it off by looking at just two modules in a fixed position. This article explains the structure of the format information, how to read it by eye, and how to confirm it with a tool.

Module density does not tell you the level

"A higher error correction level means a denser QR code" only holds when you generate the same data under the same conditions and compare the results. In practice the density of a QR code (its module count per side) depends on the amount of data and the version (1 to 40) as well as the error correction level.

So you cannot look at a single QR code and conclude "this one is dense, it must be H". A short payload produces a small symbol even at level H, and a long URL produces a fine-grained symbol even at level L. The correct way to check the level is to read the value stored inside the code, not to judge by appearance.

The level is written in the format information

Separately from the payload, a QR code carries a region called the format information. It is defined by JIS X 0510 / ISO/IEC 18004 and records the error correction level and the mask pattern number. Before extracting any data, a reader first decodes this format information to learn which level to correct with and which mask to undo.

The format information is 15 bits in total:

The whole 15-bit string is then XORed with the fixed pattern 101010000010010. That step prevents the format information from ending up all one colour, which would confuse readers. Because the format information is itself protected by a BCH code, up to 3 bit errors in it can be corrected even if that area is dirty.

The same data appears twice: the format information is placed in two locations within the symbol. The first copy wraps around the top-left finder pattern; the second is split between the area below the top-right finder and the area to the right of the bottom-left finder. If one copy is damaged, the other can still be read.

Checking it by eye: only two modules matter

Here is the practical part. Define coordinates so that the top-left module is (row 0, column 0), rows increase downwards and columns increase to the right. The top-left finder pattern occupies rows 0 to 6 and columns 0 to 6, and the separator (light) sits at row 7 and column 7. Row 8 is the format information row.

You only need the two leftmost modules of that row, that is (row 8, column 0) and (row 8, column 1), to read off the error correction level.

(row 8, col 0)(row 8, col 1)Error correction levelApproximate recovery
darkdarkLabout 7%
darklightMabout 15%
lightdarkQabout 25%
lightlightHabout 30%

These two modules are decisive because the first two bits of the format information are exactly the error correction level indicator. The indicators defined by the standard are L=01, M=00, Q=11, H=10, and XORing them with the first two bits of the mask 101010000010010, namely 10, gives precisely what you see at (row 8, column 0) and (row 8, column 1). The mask pattern number occupies the following three bits, so these two modules are unaffected by which mask was chosen. The positions and the mapping are identical from version 1 (21x21) through version 40 (177x177).

Demo: switch the level and watch the two modules change

The buttons regenerate a QR code in your browser at the selected error correction level and highlight the modules used in the table above (below the top-left finder and at the bottom of the left edge, outlined in red). Watch how the colour combination changes with the level.

Cross-checking with the second copy

Because the format information exists twice, you can verify your reading. Let N be the number of modules per side. The first two bits of the second copy are at (row N-1, column 8) and (row N-2, column 8), that is, in the column immediately to the right of the bottom-left finder, counting two modules up from the bottom. The colour combination there matches the first copy. The demo above outlines both pairs in red.

Note that the module just above the bottom-left finder, at (row N-8, column 8), is always dark by definition (the dark module). It is a handy landmark for finding where to start counting.

When this does not apply: this reading applies to ordinary QR codes (Model 2). Micro QR has only one finder pattern and a different format information structure, so it does not apply. For QR codes printed with dark and light inverted, swap dark and light when reading the table.

Checking it with a tool

Reading by eye is good for understanding the mechanism, but when the edges are unclear, as in a photograph of a printed code or a heavily styled design QR, a decoder is more reliable. Upload an image and it reports the error correction level, the version and the mask pattern together.

Free Tool Check the level with QR Code Analyzer Upload a QR code image to inspect its error correction level, version, mask pattern and stored data.

If the image is too degraded to decode at all, enhance it first and then analyse it. The steps are covered in How to Restore an Unreadable QR Code from a Photo.

Confirming the level of a code you are about to create

When you generate a code yourself, whatever you specify goes straight into the format information. If you omit it, the generator falls back to its default (M in many implementations), which is exactly how a code meant to carry a logo ends up at the default level. Checking the two modules above right after generation confirms in seconds that you got the level you intended.

Which level suits which situation is covered in How QR Code Error Correction Works.

Summary

Frequently Asked Questions

Where is a QR code's error correction level recorded?

It is recorded in a 15-bit region called the format information. To read it by eye, look at the two modules below the top-left finder pattern, at (row 8, column 0) and (row 8, column 1). Dark-dark is L, dark-light is M, light-dark is Q and light-light is H.

Does a denser grid mean a higher error correction level?

No. The number of modules per side depends on the amount of stored data and the version (1 to 40) as well as the error correction level. A higher level means a denser grid only when you compare codes generated from the same data under the same conditions.

What do the 15 bits of the format information contain?

Two bits for the error correction level, three bits for the mask pattern number, and ten error correction bits of a BCH(15,5) code protecting them. The whole string is then XORed with the fixed pattern 101010000010010.

Can the format information still be read if it is dirty?

The format information is protected by a BCH code, so up to three bit errors can be corrected. In addition the same content is placed in two locations within the symbol, so if one copy is damaged the other can still be read.

← Back to Tech Blog