Image, Sound and Media

How a QR Code Stores Information

Hand holding a QR code up to a reader in front of a wall of colorful posters
Photo: Proxyclick Visitor Management System via Pexels. Image credits

A QR code looks like visual noise, but it is a precisely organized grid. Each small square, called a module, is either dark or light and represents a single binary digit. A camera photographs the grid, software decides which modules are dark, and the resulting string of ones and zeros is decoded into text, most often a web address or a short piece of data. The code does not "contain" a website in any live sense. It contains characters that happen to be a link, and the phone decides what to do with them.

The format was created at DENSO WAVE in 1994 by Masahiro Hara and a colleague. The company tracked parts in car factories, where ordinary one-dimensional barcodes held only about twenty alphanumeric characters and could not represent Japanese characters at all. The team wanted a symbol that held far more, scanned quickly from any angle, and worked on dirty factory labels. Those three requirements explain almost every design decision in the finished code.

How the Grid Is Organized

A QR code is not simply a picture of data; it is a structured layout in which different regions play different roles. The most visible are the three large squares in the corners. Each is a dark square inside a light ring inside a dark center, and a scanner slicing through the middle of one, in any direction, meets a distinctive sequence of dark and light runs in the proportion 1:1:3:1:1. According to DENSO WAVE, Hara's team surveyed printed material such as flyers, magazines, and cardboard boxes to find the ratio least likely to appear by accident, so software can spot these markers quickly in a cluttered image.

Because only three corners carry the marker, the code's orientation is unambiguous. The empty fourth corner tells the software which way is up, and the geometry of the three markers lets it correct for a code photographed at an angle. Larger codes add smaller alignment patterns to compensate for curved surfaces, and alternating dark and light timing lines run between the markers so the reader can count modules accurately across the grid.

Size is described by a version number from 1 to 40. Version 1 is 21 by 21 modules, and each step adds four modules per side, so version 40 reaches 177 by 177. A short web address fits comfortably in a small version; a large block of text needs a large one, and the grid grows to match.

Turning Characters into Modules

Before anything is drawn, the encoder chooses a data mode. Numeric mode packs digits in groups of three into ten bits each. Alphanumeric mode handles digits, capital letters, and a few symbols, pairing characters to fit eleven bits. Byte mode stores raw eight-bit characters, and a separate mode handles Kanji. Choosing the most compact mode that fits the content is why a code made only of digits can be much denser than one holding arbitrary text. At the maximum size, the specification allows up to 7,089 numeric characters or 2,953 bytes of binary data.

The data bits are arranged in a zigzag pattern that snakes upward and downward through two-module-wide columns, skipping the reserved areas. This order is a convention fixed by the standard, which is why every compliant reader knows exactly where to look.

Surviving Damage With Error Correction

The clever part is what the encoder adds after the message itself. It calculates extra codewords using Reed-Solomon coding, a scheme introduced by Irving Reed and Gustave Solomon in 1960 and later used in compact discs, deep-space probes, and digital television. The idea is that the message is treated as the coefficients of a polynomial over a finite field, and the extra symbols are additional values derived from it. If some symbols are lost or corrupted, the receiver can solve for the missing values because the surviving data still constrain the polynomial.

QR codes offer four correction levels. Level L can restore roughly 7 percent of the code, M about 15 percent, Q about 25 percent, and H about 30 percent. The trade-off is direct: higher correction spends more of the grid on redundancy and leaves less room for the message. This is also why a logo can sometimes sit in the middle of a code and still scan. The designer sacrifices part of the error-correction budget, and the reader treats the logo as damage to be repaired. Push it too far and the code fails.

Just before finishing, the encoder tests eight mask patterns, each of which flips modules in a fixed geometric arrangement, and picks the one that avoids large solid blocks, long uniform runs, and accidental copies of the finder pattern. A small block of format information records which correction level and mask were used, so the decoder can undo the process.

From Factory Floor to Everywhere

DENSO WAVE announced the code in 1994 and made the specification openly available. It was standardized as ISO/IEC 18004 in 2000, and later editions refined the symbology. The company has stated that it waived patent enforcement for standardized QR codes, which helped the format spread far beyond automotive supply chains. Cameras in phones eventually made scanning free of dedicated hardware, and the format moved into tickets, payments, and packaging.

The camera side of the process is itself a small chain of technologies. A digital camera sensor converts light into a grid of numbers, and the software must find the code within that image before decoding anything. The older cousin of the format is the linear symbol described in how barcodes are scanned, which reads along a single line and therefore stores far less.

Limits and Misconceptions

A QR code is not encrypted. Anyone can read what it contains, and the reader displays or acts on that content. The safe habit is to check the destination a scanner shows before opening it, because a printed sticker can be placed over a legitimate code. Where secrecy matters, the protection has to come from the content itself, as explained in how encryption protects information.

Codes are also not magical about damage. Error correction has a budget, and a scratch that removes a finder pattern or a large fraction of modules exceeds it. Glare, low contrast, and blur reduce reliability long before the printed grid is physically compromised, since the camera must first decide which modules are dark. Finally, "dynamic" codes used in marketing usually do not store more data; they encode a short address that redirects elsewhere, which is why the destination can change without reprinting.

In Short

A QR code stores information as a grid of dark and light modules arranged around three corner markers, encoded in the most compact mode available, and protected by Reed-Solomon redundancy that lets a reader rebuild missing pieces. Its unusual 1:1:3:1:1 markers, orientation logic, and mask selection were all engineered to make one thing dependable: a fast, correct read from almost any angle, on a surface that is far from perfect.

Test what you learned

Three quick questions on this article. For the full experience, play the quiz on this topic.

1. How many of a QR code's corners carry the large square finder pattern?

2. What does a QR code add to the data so that damaged areas can be reconstructed?

3. Why does a QR code need a blank margin around it?

Ready for more?

Play the quiz on this topic and see the explanation behind every answer.

Play the 6-question quiz

Sources

How we choose and check sources: Sources and methodology.

Keep exploring

Warehouse worker using a handheld scanner next to shelves of blue drums
Image, Sound and Media

How Barcodes Are Scanned

A barcode scanner never reads numbers directly. It measures how long light stays dark and bright as it sweeps across bars, then a check digit confirms the read.

5 min read 6 quiz questions
Accordion file folders holding organized documents in compartments
Image, Sound and Media

How Compression Shrinks Files

Compression works by removing repetition and predictability. Lossless methods rebuild every bit; lossy methods deliberately throw away detail people rarely notice.

5 min read 6 quiz questions
Hand holding a camera body without a lens, exposing the image sensor
Image, Sound and Media

How Digital Camera Sensors Capture Images

A camera sensor is a grid of tiny light meters. Each one counts photons through a color filter, and software rebuilds a full-color picture from those counts.

5 min read 6 quiz questions
Smartphone wrapped in chains and locked with a combination padlock
Internet and Connectivity

How Encryption Protects Information

Encryption turns readable data into scrambled bytes that only a key can undo. Here is how symmetric ciphers, public-key exchange, and secure web connections fit together.

5 min read 7 quiz questions