Blog / Tech, New & Old /

How QR codes work

A QR code is a square of black and white dots that a camera turns into text, most often a web address. That’s the whole idea. You point your phone, it reads the pattern, and a link pops up.

It sounds like magic, but it’s one of the neatest bits of everyday engineering, and understanding it helps you use QR codes properly, whether you’re scanning a restaurant menu or printing one for your shop.

Where they came from

QR stands for Quick Response. The code was created in 1994 at Denso Wave, a Japanese company that is part of the Toyota group, by a team led by Masahiro Hara. The original job was practical: tracking car parts in factories. Ordinary barcodes held very little information and were slow to scan from awkward angles. The new code could hold much more and be read quickly from any direction.

Denso Wave also chose not to enforce its patent rights on the standard, which is a big reason QR codes spread everywhere without anyone paying a licence to print one.

What is actually inside

Think of a QR code as a tiny grid, like graph paper, where each square is either dark or light. Each square is called a module. A dark one is a 1 and a light one is a 0. Line them up and you’ve got a string of bits that spells out text.

Some of those squares have special jobs:

  • The three big squares in the corners. These are finder patterns. They tell the camera “here’s a QR code, and here’s which way up it is”. That’s why you can scan one sideways or upside down.
  • A smaller square near the fourth corner on bigger codes helps the software correct for a code that’s printed on a curved or tilted surface.
  • Timing lines act like a ruler, so the scanner knows how big each module is.
  • The blank border (the quiet zone) separates the code from whatever is around it.
  • Format information tells the reader how much error correction the code has.

The rest is your data, plus extra data for fixing mistakes.

Why a scratched code still works

Here’s my favourite part. QR codes include error correction, built on a maths method called Reed-Solomon codes (the same family of ideas used in CDs and in storing data reliably).

Imagine writing your phone number on a piece of paper, then also writing a few extra clues that let someone rebuild the number if a coffee stain covered part of it. That’s error correction. The code stores redundant information, so a scanner can reconstruct what’s missing.

There are four levels, from low to high. At the highest level, a good proportion of the code can be damaged or covered and it will still read. That’s why you see QR codes with a logo in the middle. The logo is blocking some modules, and the redundancy covers the gap.

The trade-off is size. More error correction means more modules for the same message, so the code looks denser. For a short web address, that’s no problem. For a long one, the code gets crowded and harder to scan from a distance.

How your phone reads it

When you open the camera:

  1. The software looks for the three finder patterns.
  2. It works out the orientation and straightens the image.
  3. It samples each module as dark or light.
  4. It applies the error correction.
  5. It decodes the result, usually a URL, and offers you a link.

Modern phone cameras do this automatically. You don’t need an app. A scanner built into the camera recognises the pattern in a fraction of a second.

QR codes are not all the same

Most of what we see are links, but a code can hold plain text, a Wi-Fi login, a contact card, a phone number or an email draft. Payments in many countries use QR codes as well.

There’s one distinction that matters if you manage a website or a small business: static versus dynamic.

A static code has the destination baked into the pattern. Change the address and you must print a new code.

A dynamic code points to a short link run by a service, and that service redirects to the real destination. You can change where it goes later, and often see scan counts. The catch is that you now depend on that service. If the account lapses, the code can stop working. For anything printed on thousands of boxes, I’d think carefully about that dependency, the same way I’d think about any redirect I don’t control. It’s the same lesson as with old tools that disappear.

The popularity story

QR codes were common in Japan for years but never took off in a big way elsewhere. Phones needed a separate app to read them, and people didn’t see the point. That changed when phone cameras started scanning them natively, and again during the pandemic, when restaurants wanted contactless menus. Suddenly everyone had scanned one.

If you want to build your own, I covered the idea of building a QR code generator with AI, which is a good way to see how simple the logic really is.

Myths worth dropping

“A QR code can hack your phone just by scanning.” Scanning alone only reads text. The risk is what you do next, like opening a fake login page or approving something. The attack is sometimes called quishing: a malicious code stuck over a real one. Treat a scanned link as you’d treat any link in a message.

“A QR code is a barcode.” They’re related, but a barcode holds a short number in one direction. A QR code stores more in two dimensions.

“Bigger is always better.” Not quite. It needs to be large enough for the distance, with clear space around it and strong contrast.

If you’re putting one on something

A short checklist:

  • Keep the destination short. Shorter links make simpler, easier codes.
  • Test it on at least two phones, in poor light, before printing.
  • Use dark on light with high contrast. Inverted or low-contrast colours confuse some scanners.
  • Leave the blank border around it.
  • Send people to a mobile-friendly page, because nearly everyone scanning is on a phone.
  • Add a few words next to it, such as “Scan for the menu”, so people know why.
  • If you want to measure scans, add tracking parameters to the link, so your analytics can tell the QR traffic from other visits.

Key takeaways

  • A QR code is a grid of squares that encodes bits, mostly a web address.
  • Corner patterns tell the camera where it is and which way up it is.
  • Built-in error correction lets damaged codes still scan.
  • Static codes are permanent; dynamic ones can be changed but depend on a service.
  • Test before printing, keep links short and send people to a mobile page.

FAQ

Do QR codes expire? A static code never does, because it’s just the data. A dynamic one stops working if the service behind it stops.

Can I put a logo in the middle? Usually yes, thanks to error correction, but test the result.

Why won’t mine scan? Usually low contrast, too small, too much data, or a glare on a glossy surface.

What’s the most useful QR code you’ve ever scanned, and the most pointless one?