QR Code Basics

How QR Codes Actually Work: From Pixels to Data

How a QR code turns a grid of black and white squares into a link, a message or Wi-Fi details — the scanning and decoding process explained simply.

Understanding how QR codes work means following a tiny journey: a camera sees a grid of black and white squares, finds its bearings, samples each square as a 1 or a 0, and rebuilds the original message — all in a fraction of a second.

It feels like magic when you point your phone at a poster and a website appears. But there's no magic — just a beautifully engineered pipeline that turns pixels into data. Let's walk through it step by step, from the moment light hits the camera to the instant the link pops up. 🐾

What is a QR code made of?

A QR code is a grid of small squares called modules. Each module is either dark or light, and that darkness or lightness represents a single binary digit — a bit. Dark usually means 1; light usually means 0. String enough of those bits together and you have bytes, and from bytes you can build text, links, or anything else.

If bits and bytes feel fuzzy, our primer on binary, bits and bytes is a gentle place to start. The short version: everything in a QR code is ultimately ones and zeros.

Step 1: How does a scanner find the code?

Before it can read anything, the scanner has to answer two questions: Where is the code? and Which way is it turned? QR codes solve this with three big nested squares in the corners, called finder patterns.

Each finder pattern has a very specific ratio of dark-to-light-to-dark when you scan a line across it — 1:1:3:1:1. That ratio is rare in ordinary images, so software can sweep across the picture, spot three of these markers, and immediately know it's looking at a QR code. Because there are three of them (not four), the scanner can also tell which corner is missing and therefore how the code is rotated.

This is the "Quick" in Quick Response: those three corner squares let the code be read from almost any angle, upside down included.

Step 2: How does it line up the grid?

Finding the code isn't enough — the scanner needs to overlay a precise grid so it knows exactly where each module sits. Several features help here:

  • Timing patterns: a dotted line of alternating dark and light modules running between the finder patterns, acting like a ruler that tells the scanner the module size and count.
  • Alignment patterns: smaller nested squares (in all but the tiniest codes) that let the scanner correct for perspective and curvature, so a code on a bent can or a tilted phone still reads.
  • Version and format information: reserved strips near the finders that tell the scanner the code's size and its error-correction settings.

Every one of these parts has a role — our anatomy of a QR code guide names and maps them all.

Step 3: How does it turn squares into bits?

With the grid locked in, the scanner samples the center of each module and decides: is this dark or light? Dark becomes 1, light becomes 0. Now the image has become a long stream of bits laid out in a specific zig-zag path that snakes up and down the columns of the code.

The mask has to come off first

Here's a twist. To keep the code readable, QR encoders scramble the pattern with a mask — a repeating pattern XORed over the data to break up large blocks of same-colored squares that would confuse scanners. The format information tells the reader which of the eight masks was used, so it can reverse it. Our piece on data masking explains why that random-looking texture is deliberate.

Step 4: How does it fix errors?

Real-world codes get scratched, smudged, printed badly, or partly covered by a logo. QR codes handle this with Reed–Solomon error correction, a mathematical method that adds redundant data so the original message can be reconstructed even when part of it is missing or wrong.

Depending on the level chosen when the code was created — L, M, Q, or H — the code can recover from roughly 7%, 15%, 25%, or 30% damage. The scanner uses the error-correction bytes to detect and repair errors before decoding. Our guides to QR error correction and Reed–Solomon, explained simply go deeper without the heavy algebra.

LevelRecoveryBest for
L~7%Clean digital screens
M~15%Everyday printing
Q~25%Industrial or dirty settings
H~30%Logos, harsh conditions

Step 5: How does it decode the message?

Now the scanner has clean bits. The first few bits form a mode indicator that says what kind of data follows — numeric, alphanumeric, byte (for general text and URLs), or Kanji. The next bits give the length. Then the actual data bits are interpreted according to that mode. Our article on encoding modes breaks down each one.

Once the bytes are decoded into text, the phone recognizes what it is — a URL, Wi-Fi details, a contact card — and offers the right action, like opening a browser. And that's the whole pipeline: locate → align → sample → unmask → error-correct → decode.

Why does the quiet zone matter?

One easily-forgotten ingredient sits outside the code: the quiet zone, a plain margin (about four modules wide) surrounding the whole thing. Without it, nearby text or artwork can bleed into the finder patterns and the scanner never locks on. It's the reason a code crammed against other content sometimes just won't read. See our note on the quiet zone for why that empty space earns its keep.

Can I see this happen myself?

Sort of! A trained eye can pick out the finder patterns, read the format bits, and even work out the encoding mode by hand. It's a fun exercise — our article on reading a QR code by eye shows how far you can get before the masking makes it too tricky.

If you'd like a clean, honest code to inspect, you can create a free QR code with QR Puppy — static, no tracking, no expiry.

Frequently asked questions

How fast does a QR code scan?

Usually a fraction of a second. Modern phones run the locate-align-sample-decode pipeline continuously on the camera feed, so the moment a valid code fills enough of the frame, it decodes almost instantly.

Why can I scan a QR code upside down?

The three finder patterns sit in three corners, not four. By detecting which corner lacks a finder pattern, the scanner works out the code's orientation and mentally rotates it before reading — so any angle works.

Does the color of a QR code affect scanning?

Yes. Scanners rely on contrast between dark and light modules. Black-on-white is safest; low-contrast or inverted color schemes can fail. If you must use color, keep the dark modules genuinely dark and the background genuinely light.

What happens if part of the code is missing?

Thanks to Reed–Solomon error correction, a code can lose roughly 7% to 30% of itself (depending on its level) and still decode. Beyond that threshold, the scanner can't reconstruct the data and the code fails to read.

Can two different QR codes contain the same data?

Two codes with the same data, version, error level, and mask will look identical. Change any encoding choice — like the mask or error level — and the same message can produce a differently-textured but equally valid code.

Make a QR code the honest way 🐾

Free forever, no tracking, no expiry — generated right in your browser.

🎨 Create a QR code →