TECHNOLOGY

How Do Barcodes Work?

Products in a grocery store
Credit: Enkhjin photography/Unsplash.com
Darren Orf
Author
Darren Orf is a writer and editor living in Portland, Oregon, who covers science and the natural world for places like Popular Mechanics, National Geographic, and Smithsonian Magazine, among others.

Walk into any supermarket and the chirp of barcode scanners easily dominates the ambience of squeaky shopping cart wheels and corporate-approved pop songs filling your ears. Without barcodes, though, buying groceries — and all kinds of retail products — would be a logistical nightmare.

Ever since the first commercial barcode was scanned some 50 years ago, these mysterious collections of black and white lines have revolutionized the shopping experience by transforming checkout queues from tedious drudgery to a streamlined process. Those lines aren’t random, though — they deliberately convey a surprising amount of information by using an efficient, tried-and-true method.

Credit: dfphotonz/stock.adobe.com

The concept behind barcodes is deceptively simple, but one that was also decades ahead of its time: binary code. Early computers were already using binary by the time the retail barcode was conceived of in the late 1940s, but the barcode is a very novel approach to employing the machine language.

The Language of Lines

The modern universal product code (UPC) features two elements: parallel black and white lines of varying thicknesses, with 12 numbers running along the bottom. Because black lines absorb light emitted from a laser scanner and white space reflects it, a laser-based barcode scanner can translate the bars into binary code — the same language used by computers. 

Black lines represent “1” and white lines represent “0,” while the thickness of the bars determines how many 1s and 0s are in a sequence. Included within the bars that represent binary are additional, longer “guard” bars that serve as boundary markers.

When scanned, a typical UPC barcode will produce a 95-character binary code that’s tied to a store’s product database, providing the correct price (along with any weekly discounts). The 12-digit code along the bottom is what’s known as a 1-5-5-1 pattern. The first number is the product type, followed by the five-digit manufacturer code, the five-digit product code, and a final check digit for the computer to ensure the barcode is read accurately. 

While UPC codes are the most common in retail stores, a variety of different barcode types are available for other applications, including logistics, distribution, or packaging too small to fit a normal barcode. A global organization known as GS1 regulates UPCs and ensures that the 2 million companies using the system have completely unique codes that work worldwide. Today, 10 billion barcodes are scanned each day — now imagine all the extra time spent waiting in line to buy your groceries if they were never invented.

Short Answer

The sequence and varying thicknesses of the black and white lines that make up a barcode translates into a string of binary code assigned to a specific product in a store’s database. The lasers in a barcode scanner are absorbed by the black bars and reflect back from the white space, generating the 1s and 0s that form the binary code, with the thickness of each bar providing additional information.