Skip to content
UseQR

Basics

How do QR codes work?

A scanner finds the three corner squares, works out the code's grid and orientation, samples every cell as black or white, reads the format bits to learn the mask and error-correction level, un-masks the data, corrects errors with Reed–Solomon, and reassembles the original text.

The decoding pipeline, in order

1. Find the finder patterns. The scanner looks for the 1:1:3:1:1 black-white ratio that finder patterns produce along any line through their centre. That ratio is rare in natural images and survives rotation, which is why a QR code can be read upside down.

2. Establish geometry. Three corners give position, scale and rotation. The missing fourth corner resolves which way up. In larger codes, alignment patterns correct for perspective and curvature.

3. Determine the grid. The timing patterns — alternating modules on row 6 and column 6 — act as a ruler so the decoder samples at the right pitch rather than assuming an even division.

4. Sample every module. The image is thresholded to black or white. This step is where low contrast, glare and blur cause failures: if the decoder cannot separate dark from light, nothing downstream can help.

5. Read the format information. A 15-bit block beside the finder patterns records the error-correction level and which mask was applied. It is stored twice and protected by its own BCH code, because everything else depends on reading it correctly.

6. Un-mask. The mask is XORed off the data area, restoring the raw bit stream.

7. De-interleave and error-correct. Codewords are put back into their original blocks and Reed–Solomon decoding repairs damage — up to about 7%, 15%, 25% or 30% depending on the level.

8. Decode the bit stream. Mode indicators say whether each segment is numeric, alphanumeric, byte or kanji, and character counts say how long each is. The bits become characters.

9. Hand it to the OS. The text is inspected for a known prefix, and the phone offers the matching action.

Why this design is robust

Every stage has redundancy. Two copies of the format information. Interleaving so a scratch spreads its damage across blocks rather than destroying one. Alignment patterns so distortion is corrected locally. Masking so no random data pattern can imitate a finder.

That is why a QR code with a coffee ring on it, photographed at an angle, in poor light, still works — and why a code with a missing quiet zone often does not, because the very first step never completes.

FAQ

Why can a QR code be read upside down?

The three finder patterns define the orientation, and the empty fourth corner tells the decoder which way up the code is. Rotation is resolved before any data is read.

How does a QR code survive damage?

Reed–Solomon error correction adds redundant codewords, and interleaving spreads them so that a localised scratch damages a few codewords in each block rather than destroying one block entirely.

What is the most common reason a QR code fails to scan?

The decoder never finding the code at all, usually because the quiet zone is too small or the contrast between dark and light modules is insufficient. Both fail before any error correction can help.

Does scanning a QR code contact a server?

Not for a static code. The text is physically in the pattern, so decoding is entirely local. Only opening the resulting link contacts anything.

Try it — free, no signup

  • What is a QR code?A QR code is a two-dimensional barcode that stores data as a grid of black and white squares. A camera reads the pattern and recovers the original text —…
  • QR code vs barcodeA traditional barcode stores about 20 characters in one dimension and must be scanned in roughly the right orientation. A QR code stores up to 2,953 bytes…