Traceable Quality
Talk to us
Menu

Insight

How do QR codes work?

What the squares mean, why a code still scans with a corner torn off, and what decides how much one can hold.

A QR code is a grid of black and white squares. Each square is a bit. Read them in the right order and you get text.

That’s all of it. The clever part is everything wrapped around those bits so a phone can find the grid, work out which way up it is, and rebuild the message when half of it is smudged.

Denso Wave invented it in 1994 to track car parts on Toyota’s assembly lines. A plain barcode held too little and was too slow to find. The factory needed something a scanner could catch from any angle. That’s still the job.

The three big squares

Look at the corners. Three of them have a large square with a smaller one inside it. The fourth doesn’t.

Those are the finder patterns. A scanner sweeping across the image looks for a black-white-black-white-black run in a 1:1:3:1:1 ratio. That ratio looks the same whether the line crosses it horizontally, vertically or diagonally, so the scanner finds the code from any direction.

Three corners also tell it the orientation. The empty corner is the bottom right. Spin the code upside down and the scanner knows.

Between the finders, a dotted line of alternating squares runs along two edges. Those are timing patterns, and they let the scanner count how many modules there are, even if the image is skewed. Bigger codes add small alignment squares inside, which correct for a curved or tilted surface.

Around the whole thing sits the quiet zone, a blank border at least four modules wide. Crop it off and many scanners won’t find the code.

What’s in the rest

A strip next to the finders holds the format information: which error correction level is in use, and which mask was applied. The rest of the grid holds the data, plus the error correction.

The mask matters more than it sounds. If your message happened to produce a big block of black, a scanner would struggle to find the edges. So the encoder tries eight mask patterns, flips squares according to each, scores the result for how scanner-friendly it is, and keeps the best one. The format strip says which.

Why it survives damage

This is the part people find hard to believe. Scratch a QR code, put a logo through the middle, tear off a corner, and it often still reads.

It’s Reed-Solomon error correction, the same maths that keeps CDs playing through a scratch. The encoder adds extra data computed from the message. When a few squares are unreadable, the scanner uses those extras to work out what was missing.

You choose how much to add.

LevelRecovers about
L7% of the code
M15%
Q25%
H30%

More correction means more squares for the same message, so a denser code. Pick L for a clean screen. Pick H if the label is going on a pallet that will be dragged across a warehouse floor, or if you want a logo in the middle.

How much it holds

Codes come in 40 sizes, called versions. Version 1 is 21 by 21 modules. Each version adds four modules per side, up to version 40, which is 177 by 177.

The biggest one, at the lowest error correction, holds roughly:

  • 7,089 digits
  • 4,296 letters and digits from a limited set
  • 2,953 bytes of anything

Those are three modes, and the encoder picks the tightest one that fits your message. Digits pack most efficiently, so an all-numeric ID makes a smaller code than the same length of mixed text.

Which is worth knowing before you print. Put a long URL in a code and it gets dense, and a dense code needs a bigger print or a better camera. A short URL that redirects makes a code that scans fast from far away. It also means you can change where it points after it’s printed.

What it’s good for on a floor

A barcode holds a number and needs a line of sight along its width. A QR code holds a lot more, reads from any angle and tolerates a scuffed label. That’s why it’s replaced barcodes in so many places.

It isn’t always the right pick. For items you can’t see, or that arrive in bulk, RFID reads without a line of sight at all. We compare them in RFID vs barcode vs QR vs BLE.

And a QR code is just data. Anyone can copy it, and nothing in it proves who made it. If that matters for your use, read QR codes that can’t be copied. For readers and printers, see our QR hardware. To make codes you can change after printing, limit by date or scans, and count, use our free QR manager.

Next step

Tell us what you are trying to trace.

Describe the flow: what arrives, what happens to it and what leaves. We will tell you what it takes to capture it.