How Barcodes Work: UPC, EAN, and the Hidden Check Digit

Those parallel black bars look arbitrary, but they encode a specific, verifiable number using a public, well-documented standard.

A barcode just encodes a number

The bars themselves don't carry a product name or price. They encode a numeric code that a store's system looks up in its own database, which is where the actual price and description live.

UPC vs. EAN: mostly a regional difference

UPC-A (12 digits) has historically been the standard in the US and Canada, while EAN-13 (13 digits) is used through most of the rest of the world. Modern scanners generally read both, and a UPC code can be read as an EAN code with a leading zero added.

The numbers are assigned by GS1, not chosen freely

A manufacturer applies to GS1, the global standards organization, for a company prefix, then assigns the remaining digits to its own products, which is why store shelves worldwide don't end up with clashing duplicate codes.

The last digit is a built-in check digit

It is calculated from the other digits using a fixed formula and appended to the code, so a scanner (or cashier typing a code by hand) can catch a single misread or mistyped digit instead of ringing up the wrong item entirely.

Not the same thing as a QR code

A traditional 1D barcode encodes a single, relatively short number and has to be scanned across the bars in one direction. A 2D QR code stores far more data and can be scanned from any angle, which is why QR codes are used for links and larger payloads instead.

A scanner reads reflected light, not a picture

The scanner shines a light across the barcode and measures how much bounces back; the varying widths of bars and gaps reflect light differently, letting the scanner reconstruct the encoded digits electronically.

Barcodes don't store the price

Because a barcode only encodes an identifying number, the price you're charged comes from the store's point-of-sale system at the moment of scanning, not from the barcode itself. That's why a shelf tag can occasionally disagree with the price that rings up if a system update hasn't caught up yet.

Why the check digit matters more than it looks

A single smudged or poorly printed bar can cause a scanner to misread one digit. Without a check digit, that error could silently ring up a completely different product; with it, the math simply fails to add up and the scanner rejects the read instead of guessing.

Frequently Asked Questions

Can two different products ever share the same barcode?

In principle, no, since GS1 prefixes are meant to keep every company's codes unique. In practice, duplicate or reused codes do occasionally show up, especially among very small or self-published products, which is one reason large retailers still verify products before adding them to a catalog.

Why does a barcode look different sizes on different packaging?

The encoded pattern of bars is what matters, not the printed size, so barcodes are commonly scaled up or down (within a supported range) to fit different packaging while still representing the exact same number.