Technical Guide

How Do QR Codes Work? Anatomy, Error Correction and Capacity

A QR code is a grid of black and white squares that stores a short piece of text. Here is what each part of the grid does, how a phone turns it back into a link in a fraction of a second, and why a scratched code often still works.

Key takeaways

  • A QR code stores text as a pattern of squares. A link is just text that the phone knows how to open.
  • Three large squares in the corners let the camera find the code, its angle and its size. The rest of the grid carries data and repair information.
  • Error correction can rebuild between roughly 7% and 30% of a damaged code, depending on the level you pick.
  • The code never contains a web page. It holds an address, and where that address lives decides how long the code keeps working.

What a QR code stores

A QR code is a two-dimensional barcode. It holds characters, usually the letters of a web address, and nothing else. There is no program inside it and no connection to the internet. When a phone camera reads the squares, it decodes them to text, and the phone decides what to do with that text.

If the text starts with https://, the phone offers to open a page. If it starts with WIFI:, the phone offers to join a network. If it is a contact card, the phone offers to save a contact. The code is the same kind of object each time. The behavior comes from the reader.

The format was created in 1994 by Denso Wave, a Toyota group company, to track car parts on assembly lines, where a plain barcode held too little. It is now an open standard, ISO/IEC 18004. The standard defines four ways to pack characters:

  • Numeric mode packs digits tightly, about 3.3 bits each.
  • Alphanumeric mode covers digits, capital letters and a few symbols.
  • Byte mode covers any text, including lowercase letters, which is why most web addresses use it.
  • Kanji mode packs Japanese characters.

A generator picks the densest mode that fits your text. Shorter data means larger squares for the same printed size, which is the main lever you control.

The anatomy of the grid

Every square in the grid has a job. The diagram shows a version 1 code, the smallest at 21 by 21 squares, which the standard calls modules. The numbers match the five parts below.

Anatomy of a version 1 QR codeA 21 by 21 module QR code with its parts numbered: finder patterns, timing pattern, format information, data and error correction modules, and the quiet zone border.12345
A version 1 code, 21 by 21 modules. Larger versions add alignment patterns, small squares that help the camera correct for bent or tilted surfaces.

1Finder patterns

The three nested squares in three corners. Scanning along any line through one of them gives the same ratio of dark and light runs, 1:1:3:1:1, so a camera can spot a code at any angle in a busy scene. The missing fourth corner tells it which way is up.

2Timing and alignment patterns

Alternating dark and light modules that act as a ruler, so the reader can work out where each square sits even if the image is stretched. Larger codes add alignment patterns for bent surfaces such as bottles and cables.

3Format and version information

Strips of modules, stored twice, that say which error correction level and which mask pattern the code uses. Codes from version 7 upward also carry the version number.

4Data and error correction

Everything else. Your text, plus extra repair codewords calculated from it. The generator also applies one of eight mask patterns that breaks up large blocks of one color, then keeps whichever mask scores best.

5Quiet zone

A blank border at least four modules wide on every side. Without it the finder patterns merge into whatever is printed nearby and many scanners give up.

How a phone reads one

The whole sequence takes a fraction of a second and runs on the phone with no network. In order:

  1. The camera finds the three finder patterns using the 1:1:3:1:1 ratio.
  2. From their positions, the software works out the code's rotation, size and perspective, then straightens the image.
  3. It samples the center of each module and records dark or light, building a grid of ones and zeros.
  4. It reads the format strips, removes the mask, and unpacks the data in the order the standard defines.
  5. It runs the error correction step, which repairs any modules it misread.
  6. It decodes the repaired bytes to text and hands the text to the camera app, which offers to open the link.

Steps 1 to 3 are where print quality matters. Low contrast, glare and blur cause the sampler to misjudge modules, and a code that is too small for the camera distance leaves each module only a pixel or two wide.

Error correction: why a damaged code still scans

QR codes use Reed-Solomon error correction, the same family of math that protects data on discs and in satellite links. The generator adds extra codewords calculated from your data. If some modules are unreadable, the reader uses those extra codewords to solve for the missing ones.

You choose the level when you generate the code. A higher level repairs more damage and uses more of the grid for repair data, so the pattern gets denser.

LevelRepairs up to aboutGood for
L7% of the codeClean screens, short text, anywhere density must stay low
M15% of the codeMost print: flyers, packaging, menus
Q25% of the codeLabels that will be handled or lightly scuffed
H30% of the codeOutdoor signs, equipment tags, codes with a logo in the middle

Two things follow. First, a logo in the middle of a code works because error correction covers the squares the logo hides, and that is why codes with logos should be generated at level Q or H. Second, error correction repairs damage. It does not repair a bad design, so a code that is already marginal on contrast or size has no headroom left for wear.

Versions and capacity

The standard defines 40 versions. Each step up adds four modules to every side of the grid, so a bigger version stores more data in a bigger pattern.

VersionGrid sizeMost data at level L
121 x 2117 bytes of text
1057 x 57271 bytes of text
40177 x 1772,953 bytes of text, or 7,089 digits

You do not pick a version. The generator picks the smallest one that fits your text at the level you chose. What you control is the length of the data. A 25-character address makes a coarse, easy pattern. A 250-character address with tracking parameters makes a dense one, and at the same printed size every square becomes about half as wide. The QR code size guide turns this into minimum print sizes.

Static and dynamic codes: where the destination lives

This is the part that decides how long a printed code keeps working. A static code stores your full address in the pattern. Scanning it opens that address directly, and nothing else is involved. It cannot be edited, and it cannot be switched off.

A dynamic code stores a short address on a redirect server. The scan opens the short address, the server looks up where it should go today and forwards the phone there. That extra step is what lets you change the destination after printing and count scans. It also means the code works only while the redirect stays hosted.

Both look the same on paper. The difference is a hosting commitment, and the cost and risk of that commitment is the subject of the static vs dynamic comparison. Permanent QR Codes sells editable codes on a one-time payment so the redirect behind a printed code does not depend on a subscription you have to keep paying.

What to check before printing

Everything above turns into a short checklist:

  • Keep the data short. Use a short address. Fewer characters mean a coarser grid and more forgiving print.
  • Pick the level for the surface. M for paper that stays clean, Q or H for anything handled, outdoors or carrying a logo.
  • Protect the quiet zone. Four modules of blank space on every side, with no text, border or fold running through it.
  • Keep strong contrast. Dark modules on a light background. Inverted codes fail on many older scanners.
  • Size it for the distance. A common rule is a code width of about one tenth of the scanning distance.
  • Scan the proof on two or three different phones, in the light where it will hang, before the full run.
  • Decide static or dynamic on purpose. If the destination might ever change, print a dynamic code from a provider that will still be there in five years.

Printing on stone, metal, glass or outdoor signage adds its own failure modes, covered in printing QR codes that last. And because a code can only be as trustworthy as the address behind it, what quishing is and how to spot it covers the risk on the scanning side.

Questions people ask

How do QR codes work without an internet connection?

The code itself needs no connection. The camera decodes the squares into text on the phone. Opening a link inside that text needs a connection, but a code holding plain text, a phone number or a Wi-Fi login works fully offline.

Who invented the QR code?

Masahiro Hara and a team at Denso Wave, a Toyota supplier, created the QR code in 1994 to track vehicle parts on assembly lines. The format is now an open standard, ISO/IEC 18004.

Which error correction level should I use?

Level M suits most print. Choose Q or H for codes that will be scuffed, outdoors or covered by a logo, and accept a denser pattern in return. Level L fits clean screens and short text.

How much data can a QR code hold?

At the largest size, version 40 at level L, a code holds up to 7,089 digits, 4,296 letters and digits, or 2,953 bytes. Real codes carry far less, because more data means smaller squares that are harder to print and scan.

Do QR codes expire?

A static code never expires, because the destination sits inside the pattern. A dynamic code points to a short address that forwards each scan, and it works for as long as that forwarding is hosted.

Print one code that keeps working for the life of the object.

Editable permanent codes cost $49 once per code, with no scan limit and no renewal. Try one free for 3 days before you pay.

Last updated: