Skip to content

Anatomy of a QR code

A QR code looks like uniform noise, but it is really half a dozen parts with completely different jobs, assembled at fixed positions. Learn which parts are fixed and the rest explains itself.

A version 3 code. Black squares are the fixed positioning parts, red dots are real data and error correction, and the grey wash marks where padding lands.

The three corner squares

Formally, finder patterns. Seven modules across, with a dark ring, a light ring and a dark core, arranged so that a scan line through the centre in any direction gives run lengths of 1:1:3:1:1. Scanners sweep the whole photo looking for that ratio.

There are three, not four, on purpose. Which corner is missing tells the decoder how the code is rotated and whether it is mirrored.

The dotted line

The timing pattern. Counting it tells the scanner how many modules the code has and how many pixels each one occupies in this particular photo. It is the ruler.

The small squares

Alignment patterns, five modules across, appearing from version 2 onward. They re-anchor the grid when the paper is curved or the photo was taken at an angle.

The strip around the top-left square

Format information: 15 bits, recorded twice in two places.

Everything else is data

Filling starts at the bottom-right corner and snakes upward two columns at a time, then shifts left and comes back down. That order is why the red dots in the diagram bunch along the left and right edges: the payload sits at the right end, the error correction bytes at the left, and the wide region between them is all padding.

Masking

Once the data is placed, one of eight lattice patterns is XORed across the data region. The standard scores four penalty rules and picks the most evenly mixed pattern. This site replaces that scoring with a whitest-result rule instead, and records the chosen number in the format strip as usual.

Versions and capacity

Size and capacity by version at error level L
VersionModulesUppercaseMixed case
V1212517
V2254732
V537154106
V745224154
V1057395271

Uppercase letters and digits switch on a dedicated mode that packs two characters into 11 bits, nearly doubling capacity. Domains are case-insensitive so that part is safe, but paths depend on the server, so check before uppercasing one.