How do barcodes work at checkout?

Published

· Last updated

A hand holds a small boxed product in front of a countertop barcode scanner glowing red at a checkout counter

How do barcodes work at checkout? A barcode does not contain a price or a product name. It holds a number, written as a pattern of dark bars and light spaces, and the scanner reflects light off that pattern to read the number. The store’s computer then looks the number up in a database to find the price. That simple design lets a cashier ring up a basket of different items in seconds.

This article explains how UPC barcodes work, from the structure of the twelve digits and the check digit that protects them, to the way a scanner reads reflected light. It also covers how barcodes work in supermarkets, which item was the first to be scanned, and how 2D barcodes such as QR codes differ.

What does a UPC barcode actually contain?

A standard UPC-A barcode contains twelve digits and nothing else. According to Mental Floss and Aspose, the first digit is a number system character that classifies the item, the next five digits identify the manufacturer, the following five identify the specific product, and the last digit is a check digit calculated from the others.

The number system digit tells the store what kind of item it is scanning. For example, Mental Floss and Accusoft both note that a leading 2 is used for weighed goods such as meat. The manufacturer and product digits are what make one box of cereal different from another box from a different company, or from a different flavor made by the same company.

How do the bars encode digits in a UPC-A code?

Each digit is drawn as a small pattern of two bars and two spaces, and the widths of those bars and spaces tell the scanner which digit it is. Seagull Scientific and Aspose both describe the encoding this way. Only numeric characters are allowed, which keeps the symbol compact and easy to read.

The symbol is divided into a left half and a right half, each carrying six digits. Between them sit special guard patterns. Morovia and Cut the Knot explain that the start and end guards are a bar, a space and a bar, while the center guard is a five-part pattern of spaces and bars that separates the two halves. These guards tell the scanner where the code begins, where it ends, and where the middle is.

The same digit is drawn differently on each side. Morovia states that left-half digits and right-half digits use different encoding schemes, and Cut the Knot adds that the two patterns are color inverses of each other. A blank margin called the quiet zone must also be kept clear around the symbol, as Softmatic and Accusoft both point out.

A printed barcode label with black vertical bars and digits stuck on a plastic-wrapped box
Illustration only: a printed barcode label on a retail package. This label is a generic example and is not necessarily a UPC-A code.

What is the check digit, and why does it matter?

The twelfth digit exists to catch mistakes. Seagull Scientific and Aspose both say it is based on the modulo 10 algorithm. In practice, Softmatic and Omni Calculator describe the same steps: multiply the digits by alternating weights of 3 and 1, add the results, and subtract the total from the next multiple of ten.

Here is that method applied to the first eleven digits 0, 3, 6, 0, 0, 0, 2, 9, 1, 4 and 5. The digits in odd positions (0, 6, 0, 2, 1 and 5) add up to 14, and multiplying by 3 gives 42. The digits in even positions (3, 0, 0, 9 and 4) add up to 16. The total is 58, the next multiple of ten is 60, and the check digit is therefore 2. Softmatic uses the same example and reaches the same answer.

According to All About Circuits, the check digit is used to verify the scan, and only a valid code leads the system on to look up the item in its database.

How does a barcode scanner work?

A barcode scanner works by shining light on the code and measuring how much light comes back. Orca Scan explains that the black bars absorb light while the white spaces reflect it, and EBSCO likewise describes one-dimensional barcodes as being read by interpreting the pattern of light that bounces back. The scanner converts that pattern of strong and weak reflections into the widths of bars and spaces, and then into digits.

Many checkout scanners use a laser. Orca Scan notes that laser scanners rely on a thin beam and an internal mirror, and are common in supermarkets, while a caption in the All About Circuits history of the UPC also refers to a laser and a moving mirror. Readers curious about another everyday sensor system can see how traffic lights detect motorcycles.

How do barcodes work in supermarkets, and where does the price come from?

In a supermarket, the price comes from the store’s computer system, not from the label. GS1, the organization that manages barcode standards, states that a standard barcode holds a number identifying the item, while the description, price and other details are stored in a database. Orca Scan agrees that the price is not stored in the barcode itself but in a pre-uploaded database of product information.

The sequence at the register therefore runs in four steps. The scanner reads the bars, the check digit confirms the read is correct, the register sends the number to the store database, and the database returns the current price. All About Circuits and EBSCO add that the same lookup records the sale and reduces the stored inventory count for that item.

In other words, the label identifies the product, and everything else about the sale is handled by software. That division of labor is why the code itself can stay so short.

What was the first barcode ever scanned?

The first product scanned at a checkout was a pack of Wrigley’s Juicy Fruit chewing gum. GS1 and History.com both place the event on June 26, 1974, at a Marsh supermarket in Troy, Ohio. Food Republic and HowStuffWorks confirm the gum and the Troy, Ohio location as well.

GS1 and Food Republic identify the cashier as Sharon Buchanan, and GS1 and All About Circuits report that the gum cost 67 cents. Marsh’s director of research and development, Clyde Dawson, took part in the occasion, according to GS1 and History.com. Because the barcode only holds a number, the same simple label that rang up that pack of gum is still the basis of retail scanning today. For another example of how food is tracked and handled behind the scenes, see what happens to unsold cruise ship food.

How do 2D barcodes such as QR codes work?

A 2D barcode stores information in both directions instead of in a single row of bars. The ANSI Blog and Barcodes Inc both explain that a QR code arranges data horizontally and vertically in a square grid. That layout lets it hold far more than a twelve-digit number, including text and web addresses.

QR codes are also built to survive damage. Both sources say they include error correction, so a code can often still be read when part of it is scratched or covered, and both note that they can be read from many angles. Instead of a laser sweeping a line, a camera takes a picture of the whole code, and software decodes it. That is why a phone can scan a QR code but is not the usual tool for ringing up a UPC at a supermarket register.

A hand holding a smartphone that displays a QR code on its screen
Illustration only: a QR code displayed on a smartphone screen.

What was left out, and why?

Several details were dropped because they appeared in only one source we could open or because sources disagreed. These include the exact time of the first scan (8:01 a.m.), the claim that the gum was chosen to show that small items could carry a barcode, the plaque at the Troy store, and the 10-pack size of the gum, each of which appeared in a single source. History.com says Clyde Dawson ceremonially scanned the gum, while GS1 and Food Republic name cashier Sharon Buchanan, and one source spells her surname differently, so we credited the cashier and described Dawson only as a participant. We also left out the invention story involving Joe Woodland, the bull’s-eye design and George Laurer, the number of modules in each UPC digit (95 in total), the year and inventor of the QR code, and the statement that some price-embedded and coupon barcodes carry a price or value, because each was supported by one source only. Finally, one source describes company prefixes of six to nine digits, which conflicts with the older five-digit manufacturer description above, so we kept to the classic breakdown and did not state exact prefix lengths as a rule.

Frequently asked questions

Does a barcode contain the price?

Generally no. GS1 and Orca Scan both state that a standard barcode holds an identifying number, and the price is kept in the store’s database and retrieved when the code is scanned.

How many digits are in a UPC barcode?

A UPC-A barcode has twelve digits, according to Seagull Scientific and Aspose: eleven digits of data followed by one check digit.

What is the check digit for?

The check digit confirms that the other digits were read correctly. It is calculated from them using a modulo 10 method, as Seagull Scientific and Aspose explain, so a misread code fails the test and is rejected.

Why can a scanner read a barcode from different angles?

Most checkout scanners use a laser and an internal mirror, as Orca Scan and All About Circuits describe, and 2D codes such as QR codes can be read from many angles, as the ANSI Blog and Barcodes Inc note. A UPC-A code also carries guard patterns that mark where it starts, ends and splits, according to Morovia and Cut the Knot.

How is a QR code different from a regular barcode?

A QR code stores data in a two-dimensional grid and includes error correction, while a regular barcode stores a short number in a single row of bars, as the ANSI Blog and Barcodes Inc explain.

Now you know that the bars at the register carry only a number and the store’s computer does the rest, and if you enjoy explanations like this, subscribe at https://www.youtube.com/@mrglobalrankss.

Related reading: How traffic lights automatically detect motorcycles and What happens to unsold cruise ship food.

Leave a Reply