How a QR Code Stores Data

undefined

A grid of modules

A QR code is built from modules — the individual black and white squares — arranged on a square grid. Each module stores one bit: black or white. Unlike a one-dimensional barcode, which reads a single line of bars, a QR code is read across the whole grid at once. The decoder converts the pattern of modules back into bytes, and those bytes become text, a URL, a Wi-Fi network or a contact card.

Finder patterns tell the scanner which way is up

In three corners of every QR code — top-left, top-right and bottom-left — sit the finder patterns: concentric dark squares surrounded by a white border. A scanner hunts for these markers to locate the code, work out its size and figure out its orientation. Because the pattern is not rotationally symmetric, the scanner can tell whether the code is upside down or sideways and rotate the image before decoding. That is why you can photograph a QR code at an angle and it still reads.

Timing patterns build the coordinate grid

Between the finder patterns run the timing patterns: alternating black and white modules along a row and a column. They act like the grid lines on graph paper, letting the scanner count exactly which module is which. Without them the scanner would know where the code is but not how finely it is subdivided.

Alignment patterns help larger codes

Bigger QR codes carry alignment patterns — smaller versions of the finder pattern scattered through the data area. They let the decoder correct for slight curvature or perspective distortion, which matters when a code is printed on a mug, a bottle or a curved sign.

Error correction is why a damaged code still scans

QR codes use Reed–Solomon error correction. Extra redundant modules are woven into the grid so missing or misread modules can be reconstructed. There are four levels: L restores about 7% of the code, M about 15%, Q about 25% and H about 30%. Higher error correction makes a tougher code, but it consumes modules that would otherwise carry data, so an H-level code holds less text than an L-level code of the same size. A generator picks the level: a code printed outdoors where it might get weathered uses H; a code on a screen where it will be pristine uses L.

This redundancy is exactly why a damaged QR code still scans. A sticker tear, a coffee stain or a crease across the middle removes some modules, but the decoder rebuilds them from the redundant copies. Only when damage passes the threshold for the chosen level does the code stop reading.

Where the actual data lives

The remaining modules, after the patterns and error correction are accounted for, hold the payload: the URL, text or other content, plus format and version information that tells the decoder which rules to use. Version 1 (21×21 modules) holds only a few dozen characters; version 40 (177×177) holds thousands. More data means more modules, which means either a bigger printed code or smaller modules — both of which affect how far away you can scan from.

Scan a QR code — free and private

← All QR guides