Guides And Insights

How QR Codes Work: Patterns, Data, and Error Correction

QR codes work by combining finder patterns, timing marks, encoded data, masks, and Reed-Solomon error correction inside one scannable grid.

8 min read

A QR code

A QR code is a data structure drawn as a square grid. The visible pattern contains orientation markers, timing marks, format metadata, encoded data, and error correction bytes.

A scanner does not read it as a picture. It finds the grid, samples dark and light modules, repairs missing data, then decodes the bit stream into the original payload.

The QR Code Generator does the reverse: it takes a URL, text, Wi-Fi record, contact card, or payment payload and renders the grid in the browser.

Modules and versions

The small squares inside a QR code are modules. A dark module represents one binary state, and a light module represents the other.

QR codes come in versions. Version 1 is 21x21 modules. Each higher version adds 4 modules per side, up to version 40 at 177x177 modules.

More data requires a larger version or denser mode. Higher error correction also increases the amount of data that has to fit.

Finder patterns

The three large corner squares are finder patterns. They let the scanner locate the code and determine orientation.

Because there are three finder patterns rather than four, the scanner can tell which way the code is rotated. It can then normalize the image before reading the data area.

Do not cover finder patterns with logos or decorative elements. If the scanner cannot locate the code, error correction never gets a chance to help.

Timing and alignment patterns

Timing patterns are alternating dark and light modules that connect the finder areas. They give the scanner a ruler for the grid.

Alignment patterns are smaller square targets used in larger QR codes. They help correct distortion from camera angle, curved surfaces, or print warping.

These patterns turn a photographed square into a measurable grid. Without them, the scanner would not know where one module ends and the next begins.

Format and version information

Format information stores the error correction level and mask pattern. Larger codes also include version information.

This metadata is repeated in protected areas of the grid so the scanner can recover it even when part of the code is damaged.

The decoder needs this information before reading the payload. It tells the decoder which mask to remove and how much correction data to expect.

Encoding modes

QR codes can encode data in different modes:

ModeGood fit
numericdigits only
alphanumericuppercase letters, digits, and a limited symbol set
byteURLs, UTF-8 text, mixed content
Kanjispecific Shift JIS character ranges

Mode selection affects capacity. Numeric data packs more tightly than arbitrary bytes. A long URL with mixed characters takes more space than a short numeric ID.

Masking

Raw encoded data can accidentally create patterns that are hard to scan, such as large blank areas or shapes that resemble finder patterns.

QR encoders apply one of eight mask patterns to distribute dark and light modules more evenly. The encoder scores the result and chooses the mask with the least troublesome visual structure.

The chosen mask number is stored in the format information so the decoder can reverse it.

Reed-Solomon error correction

QR codes use Reed-Solomon error correction. The encoder adds correction bytes derived from the payload. During scanning, the decoder uses those bytes to detect and repair missing or wrong data.

The four QR error correction levels are:

LevelApproximate recovery
L7%
M15%
Q25%
H30%

Higher levels make the code more tolerant of damage, but they also make the grid denser for the same payload.

The decoding pipeline

A scanner usually follows this sequence:

  1. find the three finder patterns
  2. estimate perspective and straighten the grid
  3. sample modules using timing and alignment patterns
  4. read format and version information
  5. unmask the data modules
  6. apply Reed-Solomon correction
  7. decode the bit stream by mode
  8. return the payload

Each step depends on the previous one. A QR code with a perfect payload can still fail if glare hides a finder pattern or the quiet zone is too small.

Quiet zone and contrast

The quiet zone is the empty margin around the QR code. It separates the grid from nearby text, borders, photos, and other graphics.

Keep at least 4 modules of clear space around the code. If a dark border or logo touches the grid, the scanner may treat it as part of the code.

Contrast matters too. Dark foreground on a light background is the safest pattern. Inverted, low-contrast, or transparent designs need real device testing before print.

What logos change

A centered logo covers data modules. Error correction can repair some of that loss, but only within limits.

If you add a logo:

  • use Q or H error correction
  • keep the logo away from finder and timing patterns
  • keep the code large enough for the denser grid
  • test the final exported image, not only the preview

The code is not valid because it looks like a QR code. It is valid because a scanner can recover the data from the sampled grid.

Read More From Our Blog

Read the blog →

Explore Our Tools

Browse all tools