I built a QR code with my bare hands to see how it works
Based on Veritasium's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.
QR codes won by combining high data capacity with redundancy that can reconstruct messages when a significant fraction of the code is missing.
Briefing
QR codes won because they solved a practical problem humans didn’t even think to ask for: reliable, high-capacity machine-readable storage that still survives real-world damage. The journey runs from early communication systems—Morse code’s dots and dashes—to barcodes built for grocery checkout, and then to QR codes designed to carry far more information than a single product ID. Once QR codes could store structured data and recover from scratches or partial loss, they became the default for everything from menus and tickets to health records and contactless payments.
The transcript traces that shift through two key constraints: capacity and robustness. UPC barcodes can uniquely identify items using 12 digits, but that format is fundamentally limited—one code means one product. When authorities needed to track beef sources during outbreaks of bovine spongiform encephalopathy (“mad cow disease”), barcodes weren’t enough. Stacking barcodes (Code 49, a predecessor to PDF417) helped only a little, and NASA’s Vericode for tracking space shuttle parts showed that two-dimensional codes could work, but early implementations were proprietary or inefficient.
That set the stage for QR codes, driven by a manufacturing headache at DENSO. Masahiro Hara wanted a way to avoid scanning multiple barcodes while filling in the same box of car components. The QR design starts with encoding text into bytes using ASCII—an approach with roots in Morse code’s character-to-symbol thinking. A “version 2” QR code is built on a 25×25 grid, and larger versions scale up to 177×177, enough for kilobytes of data. The structure is standardized: three large “position” squares anchor orientation, timing strips help define the grid, and an alignment pattern lets scanners rescale the code when viewed from angles.
Inside the grid, data placement follows a zigzag path starting from the bottom right. The first bits specify the data mode (numeric, alphanumeric, byte, or Japanese kanji) and the character count, then the message bytes are written in a defined order. Crucially, the QR code doesn’t just store data—it stores redundancy. Error correction levels (low, medium, quartile, high) allow the code to be reconstructed even when up to roughly 30% is missing. The transcript links that resilience to Reed–Solomon error correction, a method developed by Irving S. Reed and Gustav Solomon and used in high-noise environments like deep-space communication (including NASA’s Voyager).
Even with error correction, QR codes can fail if their pixel patterns accidentally resemble large blank or damaged regions. To prevent that, QR codes apply one of eight masking patterns that reshuffle pixel appearance while leaving the functional elements intact. The “best” mask is chosen by scoring how readable the result is—lower score means easier scanning.
The final arc explains why QR codes became ubiquitous: DENSO Wave made QR code patents open to everyone, monetizing scanners instead. Smartphone camera integration in 2017 accelerated adoption, and the COVID-19 pandemic pushed QR menus and contactless payments worldwide. The transcript also flags safety: QR codes can be used for scams, so users should verify where a scan leads before clicking. Looking ahead, the supply of usable QR patterns is effectively inexhaustible, making QR codes a long-term communication tool rather than a temporary fad.
Cornell Notes
QR codes became dominant because they combine high information capacity with built-in error correction and standardized scanning features. They encode text using byte/ASCII-based schemes, place data in a precise zigzag pattern anchored by three position squares, and add redundancy so the message can be reconstructed when the code is scratched or partially missing. Reed–Solomon error correction underpins that resilience, and masking patterns reduce the chance that random-looking pixel arrangements confuse scanners. Open patent policy from DENSO Wave plus smartphone camera support turned QR codes from an industrial tool into a mainstream interface for payments, menus, and health records.
Why were UPC barcodes insufficient for tracking problems like mad cow disease?
How does a QR code’s physical layout help a phone read it reliably?
What role do error correction levels play, and how much damage can a QR code tolerate?
Why are masking patterns necessary even when error correction exists?
How does Reed–Solomon error correction fit into QR decoding?
What factors turned QR codes into everyday infrastructure?
Review Questions
- What specific QR code features allow a scanner to determine orientation and correct for viewing angle distortions?
- Explain how error correction redundancy and masking patterns work together to keep QR codes readable under real-world damage and confusing pixel arrangements.
- Why did open patent policy and smartphone camera integration matter as much as the underlying encoding technology?
Key Points
- 1
QR codes won by combining high data capacity with redundancy that can reconstruct messages when a significant fraction of the code is missing.
- 2
UPC barcodes are optimized for product identification, but outbreaks and supply-chain tracking demanded more information per item than 12 digits can carry.
- 3
QR codes use standardized structural elements—position squares, timing strips, alignment patterns, and format information—to make decoding consistent across devices and distances.
- 4
Data mode bits, character counts, and a defined zigzag placement rule determine exactly how text becomes pixels in the grid.
- 5
Reed–Solomon error correction (using finite-field arithmetic) powers QR codes’ ability to survive scratches, stains, and partial loss.
- 6
Masking patterns reduce the chance that pixel arrangements accidentally mimic damage or non-QR patterns, and scanners select the mask with the best readability score.
- 7
QR adoption accelerated due to open patent policy from DENSO Wave and built-in QR scanning in smartphone camera apps, with COVID-19 boosting contactless use cases.