How QR Codes Actually Work (and How They Fail)
Web & Networking - 6 min read - Published 2026-09-06
A QR code can survive a torn corner, a coffee stain, or a logo printed right in the middle of it, and often still scan successfully. That resilience isn't an accident or a lucky side effect - it's a deliberate, mathematically real feature built into the format from the start.
It's Not Just Black and White Pixels
A QR code encodes data as a grid of black and white squares, but the raw data isn't stored directly, pixel to bit. It first passes through Reed-Solomon error correction, an algorithm that deliberately adds redundant data alongside the original - similar in spirit to how a RAID array or a CD can survive some physical damage. This is what makes partial damage survivable: the redundant data lets a scanner mathematically reconstruct the original message even if a meaningful chunk of the code is missing or misread.
The Four Error-Correction Levels
QR codes support four error-correction levels, each trading data capacity for damage resistance: Level L can recover from about 7% of the code being unreadable, M about 15%, Q about 25%, and H about 30%. Higher error correction means a denser, more complex-looking code (since more of it is redundant data rather than the actual payload), which is exactly why QR codes with a logo overlaid in the center are typically generated at level H - enough redundancy is built in to survive that intentional obstruction.
The Three Corner Squares Aren't Decoration
The three larger square patterns in three corners of every QR code (deliberately absent from the fourth) are position markers, letting a scanner instantly determine the code's orientation and boundaries regardless of the angle or rotation it's photographed at. This is why you can scan a QR code from an angle, upside down, or at a distance and it still works - the scanner isn't relying on the image being perfectly aligned.
Why QR Codes Still Sometimes Fail to Scan
Given all this built-in resilience, real scan failures usually come down to a few specific, avoidable causes: insufficient contrast between the light and dark modules (a light gray on white QR code has much less margin for error than true black on white), too little blank margin around the code's edge (the "quiet zone" the scanner needs to detect the code's boundary), or simply encoding so much data that the resulting code is too dense for a phone camera to resolve clearly at typical scanning distance. None of these are QR code failures exactly - they're the redundancy budget being exceeded by real-world imperfection.