How QR Codes Work - How Black and White Squares Carry Information
QR Codes Are "Two-Dimensional Barcodes"
Barcodes on supermarket products encode information using only horizontal line widths. QR codes arrange black and white cells (modules) in both vertical and horizontal directions, storing far more information. This is why they're called "two-dimensional codes."
Black modules represent "1" and white modules represent "0." This sequence of 0s and 1s becomes data. Since all computer data can be expressed in 0s and 1s, QR codes can store URLs, text, phone numbers, and various other information.
Three Large Squares Serve as Landmarks
The large squares at three corners of a QR code are called "finder patterns" - the first landmarks scanners look for. By finding these three squares, scanners instantly determine the QR code's position, size, and tilt.
Having squares at only three corners allows the remaining corner (bottom-right) to be inferred, enabling correct reading regardless of orientation. This is why QR codes can be scanned even at an angle.
"Error Correction" Reads Even Damaged Codes
QR codes contain "error correction codes" - repair data alongside the actual data. This enables mathematical restoration of lost data even when parts of the QR code are dirty or damaged.
Error correction strength has four levels (L, M, Q, H). At the strongest H level, the code remains readable even with about 30% damage. This is also why QR codes with logos overlaid in the center still scan correctly.
Timing patterns and locating positions
To read a QR code correctly, the reader needs to grasp accurately where the countless cells are arranged. What helps with this is a dotted pattern of alternating white and black, placed so as to connect the three large squares. This is called the timing pattern, and it serves as the reference for the reader to work out the spacing and position of the cells. In addition, large codes add small squares for alignment, so that even if the code is photographed slightly distorted, the grid can be restored accurately.
How black and white represent information
Each cell of a QR code represents the smallest unit of information by being white or black. By treating black as 1 and white as 0, the arrangement of cells is replaced by a sequence of numbers, which is assembled into the information of characters and URLs. The margin secured around the code is indispensable for making this reading work. The margin separates the code from the background and tells the reader where the code begins. A simple combination of black and white can carry rich information through these devices.
Why QR codes spread worldwide
QR codes were originally developed in Japan to make the management of auto parts more efficient. One big reason they came to be widely used is that the standard was made public so that anyone could use it freely. Because patent rights were not asserted, various companies could adopt it without worrying about cost. In addition, the convenience of being read quickly from any direction connected with the spread of smartphones, and they came to be used in every kind of situation around the world, from payment to information display.
From Scan to Display
When scanning a QR code with a smartphone, these processes occur internally:
- The camera detects finder patterns in the image, identifying the QR code's position and orientation
- Each module (black/white cell) is read and converted to a data sequence of 0s and 1s
- Error correction codes repair scanning errors and damage-caused gaps
- The repaired data sequence is decoded into a string (URL or text)
- Based on the decoded result, actions like opening a browser or saving a contact are executed
This entire process completes in a fraction of a second, making it feel like the page opens the instant you scan.