What’s a QR code, really?
A QR ("Quick Response") code is a 2D barcode invented in 1994 by Denso Wave to track car parts on factory floors. Unlike a regular barcode that only stores ~20 characters in one direction, a QR can pack up to 7,089 numeric or 4,296 alphanumeric characters into a square pattern — enough to fit a URL, a contact card, a payment request, or a short message.
The anatomy of a QR code
Every QR code has a few telltale pieces. The three big squares in the corners are Position Detection Patterns — they tell the scanner "this is a QR code, here’s how it’s oriented". Smaller squares (alignment patterns) help correct for distortion if the code is photographed at an angle. The alternating black/white timing pattern is the ruler. The format area says how strong the error correction is. The rest is your data, wrapped in a white "quiet zone" so cameras can see where the code ends.
- Position patterns: the three big corner squares
- Alignment patterns: the small squares for distortion correction
- Timing patterns: the ruler that tells the scanner the module size
- Format area: stores error-correction level + masking pattern
- Quiet zone: the white margin (at least 4 modules wide)
How data is squeezed in
The encoder converts your input into binary, chooses the most efficient mode (numeric, alphanumeric, byte, or kanji), wraps it in Reed-Solomon error correction codes, lays it out in the matrix, then applies one of eight mask patterns to keep the visual contrast balanced. All that happens in a few milliseconds in your browser — no internet required.
Why it still scans with a coffee stain on it
Reed-Solomon error correction is the magic. The encoder bakes redundant data into the pattern so a scanner can recover even when chunks are damaged or obscured. There are four levels you can pick from — L (7% loss tolerance), M (15%), Q (25%), and H (30%). That’s why you can put a logo in the middle without breaking anything: the error-correction codes fill the gap.
- L = Low — fastest scan, lowest tolerance (7%)
- M = Medium — the sweet spot for most use cases (15%)
- Q = Quartile — good for slightly damaged codes (25%)
- H = High — required when you embed a logo (30%)
What happens when you scan
The camera captures a frame, the scanner finds the three position patterns, calculates orientation, reads the format info to learn the EC level, reverses the mask, applies error correction to fix any damaged modules, then decodes the binary back into text. If the text starts with "http://", "wifi:", "mailto:", or another known scheme, your phone offers an action. All of that happens in roughly 30–70 ms.
- A bigger QR code = easier scanning. Rule of thumb: scan distance ≈ 10× code width
- Always leave a white quiet zone (4 modules) around the code
- Use error-correction H whenever you add a logo
- Dark foreground on light background scans 3× faster than the reverse
- QR codes don’t need internet — they encode data directly
Now that you know how the pattern works, designing one that actually scans gets a lot easier.