← All posts
7 min read

QR codes from first principles: how those black-and-white squares actually work

A friendly tour of QR codes — what every block means, why they survive damage, and what static vs. dynamic really gets you.

QR basicsEducation

A QR code looks like static, but every pixel is doing a job. Understanding the layout takes the magic out and replaces it with something more useful: an intuition for what you can change, what you cannot, and why a code that looks fine on screen sometimes fails in the wild.

What a QR code actually encodes

QR stands for Quick Response. It is a 2D barcode invented in 1994 by Denso Wave to track car parts on a factory floor. Where a 1D barcode stores data along one axis, a QR code uses a grid of dark and light modules — small squares — to store data in two dimensions. That is why it can hold more in less space and still be read at an angle.

The data inside a QR code is just bytes. Most of the codes you scan in the wild contain a URL, but the spec also supports plain text, contact cards (vCard), Wi-Fi credentials, calendar events, payment instructions, and more. The scanner does not care about meaning — it decodes bytes and hands them off to the operating system, which decides what to do with them.

Anatomy of the grid

Look closely at any QR code and you can pick out a few fixed structures. These are the parts a scanner uses to orient itself before it ever tries to read your data.

  • Finder patterns — the three large nested squares in the corners. They tell the scanner: this is a QR code, and here is its rotation.
  • Alignment patterns — smaller nested squares scattered through bigger codes. They correct for perspective when the code is read at an angle or printed on a curved surface.
  • Timing patterns — the alternating dark/light line running between the finders. It tells the scanner the size of one module so it can sample correctly.
  • Format and version info — strips near the finders that encode the error-correction level and the QR version (which determines grid size).
  • Quiet zone — the empty margin around the code. Without it, scanners often fail to lock on, even if the code itself is perfect.
  • Data and error-correction modules — everything else. The actual payload, plus redundancy.

Why a torn QR code still scans

QR codes use Reed–Solomon error correction, the same family of math that keeps CDs playable through scratches. There are four levels: L (~7% recovery), M (~15%), Q (~25%), and H (~30%). At level H, roughly a third of the modules can be missing or wrong and the code still decodes. That is the budget that makes artistic QR codes possible — when you place a logo in the middle, you are spending part of that error-correction headroom.

Static vs. dynamic QR codes

A static QR code encodes its destination directly. The URL you put in is the URL the scanner sees. It is fast, free of any infrastructure, and works forever — but if the destination changes, you have to print a new code.

A dynamic QR code encodes a short redirect URL pointing to a service you control. When someone scans it, the service looks up the current destination and forwards them. The image on the wall never changes; the destination behind it can. That is what unlocks editing, A/B testing, scan analytics, geo-routing, and time-of-day rules — none of which are possible with a static code.

When each one wins

  • Static — Wi-Fi codes, vCards, anything you want to work offline forever, anything you do not want to depend on a third-party service for.
  • Dynamic — marketing campaigns, packaging, signage, anything where the destination might evolve, and anything where you want to know who scanned and when.

The takeaway

A QR code is a self-describing little protocol. Once you can name the finder patterns, the quiet zone, and the error-correction level, the rest of the choices in this space — design, scanability, dynamic routing — stop feeling like dark arts and start looking like engineering trade-offs you can actually reason about.