How do QR codes work?

What is inside those little squares, why they still scan with a logo on top or half scratched away, and the four rules that separate a QR code that works from one nobody can read.

By , Full stack developer

On this page

A QR code looks like noise. It is precisely the opposite: every little square is where it is for a reason, and a good share of them do not contain your link at all — they contain instructions so a camera knows how to read the ones that do.

Understanding that structure is useful for something very concrete: no longer printing codes that fail to scan. Almost every QR code that fails does so for the same four reasons, and all four are avoidable once you know what is inside.

What is a QR code?

It is a matrix of modules — the little squares — in black and white, not an image. The difference matters: a QR code cannot be stretched, cropped or “improved” by retouching, because each module is a bit of information sitting in a fixed position.

Denso Wave, a Toyota subsidiary, invented it in 1994 to track parts on an assembly line. Two of its traits come from there: it reads at any angle, and it tolerates being dirty.

The anatomy

Look closely at any QR code and you will see parts that repeat in all of them:

  • The three squares in the corners are the position patterns. They tell the camera where the code is, at what scale and at what rotation. They are why you can scan it upside down.
  • The small square near the fourth corner is the alignment pattern, correcting distortion when the paper is curved or the photo comes out skewed.
  • The two dotted lines joining the corners are the timing pattern: they fix the exact module size.
  • The strips beside the corners hold the format: which error correction level it uses and which mask was applied.
  • Everything else is your data and its redundancy.

The matrix size is called the version, running from 1 (21×21 modules) to 40 (177×177). The more you put in, the larger the matrix, and the smaller each module ends up when printed in the same space. That is why a short link scans better: not superstition, geometry.

Why does it read even when damaged?

Here is the elegant part. A QR code stores data with Reed-Solomon error correction, the same family of maths that let a scratched CD keep playing. There are four levels:

  • L — recovers up to 7% of the code being damaged.
  • M — up to 15%.
  • Q — up to 25%.
  • H — up to 30%.

That is where the logo-in-the-middle trick comes from: the reader is not “ignoring” that area, the information you covered is duplicated elsewhere. At level H you can cover close to a third of the code and still have it work.

With two warnings. First: raising the correction level makes the code bigger for the same data, because the redundancy takes room. Second: the logo goes in the centre and never over the corner squares — those are not data, they are the references the camera needs to find the code at all, and without them there is nothing left to correct.

The four rules that make it work

Margin. A QR code needs a quiet zone of four modules all around it. This is the most common design mistake: pushing the code to the edge of a flyer or dropping it inside a coloured box. With no margin, the camera cannot find where it starts.

Contrast and polarity. Dark on light, always. Readers expect dark modules on a light background; inverting it — light on dark — fails on many scanners. And a pastel-coloured QR on white has the same problem as light grey text: not enough contrast to tell module from background.

Size. The working rule is 1:10: the code should measure roughly one tenth of the distance it will be scanned from. For a poster read at two metres, about 20 cm. For a card held in the hand, 2 cm is plenty. Below 2 cm printed, it starts becoming a lottery.

Proportion. It is square and it stays square. Stretching it to fit a gap breaks the geometry the reader uses to work out module size.

Static or dynamic?

A static QR code carries the destination written inside it. It is permanent: if the link changes, you reprint.

A dynamic one carries the address of a middleman that redirects. It lets you change the destination and count scans, but it introduces an uncomfortable dependency: if that service shuts down, raises its price or lets the account lapse, every printed code stops working at once. We have seen flyers and plaques go silent that way.

The recommendation is simple: if you are printing something that lasts years — a plaque, a menu, packaging — point the QR at a domain you own. From there you can redirect wherever you like, and the redirect is yours to control.

A QR code accepts plain text, and conventions are built on top of that: WIFI: to join a network without dictating the password, BEGIN:VCARD for a contact card, mailto: or tel: to open mail or the phone. Any generator writes those, including ours, which also exports SVG so your printer does not receive a pixelated PNG.

And before scanning someone else’s

The flip side of a QR code being illegible to humans is that you do not know where it leads until you are already going there. There is a scam named after it — quishing — that consists of exactly that: stickers placed over the legitimate QR code on a parking meter, a poster or an invoice.

The defence is reading it before opening it. Our QR code reader shows the contents as text and opens nothing on its own: you decide after seeing the full address. Half a minute that saves the trouble.


A QR code is a thirty-year-old piece of engineering that still works because it assumed from the start that the real world is dirty, crooked and badly lit. It deserves the margin, the contrast and the size it asks for.

Shall we talk about high-traffic niche landing pages?

Tell us your case and we come back with a first read on scope within one business day.

We reply within one business dayBogotá · UTC−5

Message us on WhatsApp (opens in a new tab)