QR codes, like the barcodes they enhance, convey information through a graphical code of black and white pixels. Where a barcode is one-dimensional, a QR code is two-dimensional. In this content it means that information is conveyed by reading both the horizontal and vertical locations of the pixels, rather than simply the horizontal position.
As such, humans can decode parts of a QR code and translate the contents manually, though it is generally tedious and time-consuming. There is generally far more information included in a QR code than the short numerical strings contained in a UPC barcode, meaning human decoding is not necessarily useful or timely.
QR codes can be decoded by any smartphone and dedicated QR scanners and can contain any textual string. This allows web addresses to be encoded in QR codes, which can automatically send the scanning device to the specified URL in the default browser. Unlike barcodes, QR codes also include an error-checking component. This means the QR code can still be successfully decoded even if parts of the code are unreadable.
Common Uses of QR Codes
QR codes are robust and durable with greater capacity and reliability than the bar codes they replace. They also improve on magnetic strips, since there’s no risk of demagnetization, and the code can be decoded manually with a reader if necessary.
This has encouraged governmental and non-governmental agencies to adopt QR codes for use on travel documents, passports and licenses, typically duplicating the information in a machine-readable format. QR codes are also widely used in advertising to provide quick links to web assets or app downloads. You can also find QR codes used for payment links, one-time password authentication, Wi-Fi login, and hundreds of other specific applications.
Anatomy of a QR Code
The most visually-distinct element of the QR code is the square blocks used for orienting the code when scanned by the reader. This permits the code to be scanned at any orientation, including upside down, and to convey the correct message. These four blocks (three in the corners and one embedded in the lower right) appear in every code and allow the code to be decoded correctly at any orientation.
Around these blocks, format version, error checking version, and decoding mask are encoded. The QR code is surrounded by an area of white space called the “quiet zone” which helps the reader find the edges of the code.
QR codes can come in a range of sizes. The largest QR code, which measures 177 x 177, holds as much as 1,264 characters of ASCII text. The most commonly used size of QR is between 29 x 29 and 33 x 33, which can hold about 50 ASCII characters. All sizes are interoperable with modern reading devices like smartphones.
QR Code Anatomy: Error-Checking and Masking
The number of error-checking bits is determined by the enforced error-checking level, called the EDC level. Depending on the EDC level used, different numbers of characters can be recovered if lost or missing. The higher the level of error-checking, the less space left over to contain the message. Most QR code generators will employ the correct level of error correction for the message length and dimensions.
- L (Low) 7% of characters can be restored.
- M (Medium) 15% of characters can be restored.
- Q (Quartile) 25% of characters can be restored.
- H (High) 30% of characters can be restored.
Bits are masked to ensure that the data is expressed efficiently (avoiding all zeros or all ones, for example). This mask is represented as a binary string, which is mathematically combined with the message to produce the QR code. This does not encrypt the message, and the “key” required to decode the masking is included with the QR code.
QR Code Anatomy: Reading QR Codes
The QR code is read from the lower-right corner. Pixels are read as groups of 8, contained one byte per 8 pixels. Depending on how the QR code is encoded, these bit patterns will be linked to different characters. While ASCII is likely the most common encoding, the specification also includes options for numerals, kanji, and other encodings. The four-bit pattern in the lower-right of the QR code (marked “Enc” in the diagram above) determines how the bits will be decoded.
QR codes are tedious to decode manually, but if you know how to read the code, it is technically possible. The flexibility and robustness of QR codes ensures they will remain a popular barcode format for the foreseeable future.
Image credit: Yaohua2000