Get AI summaries of any video or article — Sign up free
I built a QR code with my bare hands to see how it works thumbnail

I built a QR code with my bare hands to see how it works

Veritasium·
5 min read

Based on Veritasium's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

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?

UPC barcodes are designed to identify a specific product using 12 digits, which effectively maps to one item type. When health officials needed to track the source and history of beef, they required more information than a single product ID. The transcript notes that barcodes couldn’t store enough data per item, prompting attempts like stacking barcodes (Code 49, later tied to PDF417) and then moving to two-dimensional codes.

How does a QR code’s physical layout help a phone read it reliably?

A QR code includes three large position squares in the corners to establish orientation, plus timing strips that connect the position squares and define the grid. An alignment pattern helps rescale the code when viewed from different distances or at oblique angles. The data itself starts at the bottom right and is written in a zigzag pattern, while format information in the format strip tells the scanner key rules for decoding.

What role do error correction levels play, and how much damage can a QR code tolerate?

QR codes use four error correction levels—low, medium, quartile, and high—corresponding to about 7%, 14%, 25%, and up to 30% of the code being missing while still remaining readable. Higher levels require more space for redundancy, reducing the space available for raw data. The transcript also describes how the error correction level is protected by duplicated format bits and additional error-correcting bits.

Why are masking patterns necessary even when error correction exists?

Sometimes the encoded data can accidentally create large uniform-looking regions (clean black/white patches) that resemble damage or non-QR patterns. That can confuse scanners expecting a noisier checkerboard. QR codes apply one of eight masking patterns that reshuffle pixel appearance (e.g., flipping white/black in certain columns) without changing the functional elements, then choose the mask with the best readability score.

How does Reed–Solomon error correction fit into QR decoding?

The transcript describes Reed–Solomon as a polynomial-based error-correcting scheme (developed by Irving S. Reed and Gustav Solomon) that can detect and correct errors with only a modest increase in data. It uses finite-field arithmetic (Galois fields) in practice to avoid coefficient blow-ups and to generate the error-correction terms that fill the QR code’s redundancy area. Reed–Solomon also underlies other systems, including NASA’s Voyager communications and the ability of scratched CDs/DVDs to still play.

What factors turned QR codes into everyday infrastructure?

DENSO Wave’s decision not to enforce QR code patents made the technology open and widely adoptable. Smartphone camera apps built-in QR scanning (Android and Apple camera integration in 2017) removed friction. The COVID-19 pandemic further accelerated use cases like contactless menus and payments, including large-scale QR transactions in India and China, plus storage of vaccine and health records in phone wallets.

Review Questions

  1. What specific QR code features allow a scanner to determine orientation and correct for viewing angle distortions?
  2. Explain how error correction redundancy and masking patterns work together to keep QR codes readable under real-world damage and confusing pixel arrangements.
  3. Why did open patent policy and smartphone camera integration matter as much as the underlying encoding technology?

Key Points

  1. 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. 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. 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. 4

    Data mode bits, character counts, and a defined zigzag placement rule determine exactly how text becomes pixels in the grid.

  5. 5

    Reed–Solomon error correction (using finite-field arithmetic) powers QR codes’ ability to survive scratches, stains, and partial loss.

  6. 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. 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.

Highlights

QR codes store far more than product IDs by encoding text into bytes and using a structured grid that can hold kilobytes in larger versions.
Error correction levels let QR codes remain readable even when roughly up to 30% of the code is missing, thanks to Reed–Solomon redundancy.
Masking patterns reshuffle pixel appearance to prevent accidental “blank patch” patterns from confusing scanners.
DENSO Wave’s choice to keep QR code patents open helped turn a technical solution into a universal standard.

Topics

Mentioned

  • DENSO Wave
  • Drexel University
  • DENSO
  • NASA
  • Saily
  • Jif
  • Samuel Finley Breese Morse
  • Joseph Henry
  • Alfred Vail
  • Bernard Silver
  • Norman Joseph Woodland
  • Masahiro Hara
  • MattKC
  • Irving S. Reed
  • Gustav Solomon
  • Richard Hamming
  • UPC
  • PDF417
  • QR
  • ASCII
  • Galois fields