How does a barcode work?

Those black stripes that go 'beep' at the checkout hide a number. How the scanner reads the bars with light, and what the digits really mean.

A “beep” sounds at the supermarket checkout and, in an instant, the product’s name and price appear. Behind that everyday gesture is an ingenious technology that has been moving world commerce for decades. But what exactly are those black stripes, and how does the machine “read” them?

Stripes that are numbers

The first thing to understand is that a barcode doesn’t store the price or the name of the product. What it contains is, quite simply, an identification number. The bars and spaces of varying thickness are just a way of writing that number in a language machines read very fast.

The most common format in stores is the EAN code (in Europe and much of the world) or the UPC (in North America), standards managed by the organization GS1. Each product has a unique number that identifies it worldwide.

How the scanner reads it

Here’s the magic. The barcode reader works with light, usually a red laser or an image sensor. The trick is based on a simple principle:

  • The black bars absorb the light.
  • The white spaces reflect it.

The scanner shines light on the code and measures what comes back. As it passes over the stripes, it receives a pattern of reflections and absences: lots of reflection (white), little reflection (black), and so on. As HowStuffWorks explains, that pattern of light and shadow is translated into a sequence of ones and zeros, and from there, into the number that identifies the product.

From the bar to the price

Once the scanner has “read” the number, the second step happens: the register looks up that number in the store’s database. That’s where the name, the price, and other product data are stored. That’s why:

  • The same product can cost different amounts in two stores: the bar is identical, but each database has its own price.
  • Changing a price doesn’t require reprinting labels: you just update the database.

The code only says “I am product X”; the store’s system does the rest.

The digit that prevents errors

Barcodes include a safety trick: the last digit is a “check digit.” It’s calculated from the other numbers using a formula. When the scanner reads the code, it redoes that calculation and confirms it matches. If it doesn’t add up, it knows there was a reading error and rejects the data. That’s why sometimes you have to scan a product twice.

From the supermarket to parcel delivery

Although they were born to speed up supermarket checkouts in the 1970s, today barcodes are everywhere: parcels, airline luggage, hospitals, inventories, and libraries. And they’ve evolved into 2D formats like the QR code, capable of storing much more information in a square.

A universal language of stripes

Barcodes are a perfect example of invisible technology: simple, cheap, and so effective that we use it a thousand times without thinking about it. The next time you hear that “beep,” you’ll know what happened: a light read a number, and a database did the rest.

Sources

  1. What is a barcode? — GS1
  2. Universal Product Code (UPC) — Encyclopaedia Britannica
  3. How UPC barcodes work — HowStuffWorks

← Back to How It Works