10,000+ happy Canadian customers | 3m+ Barcodes sold globally | 10,000+ scans each day

UPC-A and EAN-13 Symbology: How barcodes are encoded

To understand how barcodes are encoded, it helps to separate two things: the number itself, which ends in a check digit, and the bars, which carry that number in a form a scanner can read. Both work the same way for UPC-A and EAN-13.

The check digit

The last digit of every UPC-A and EAN-13 is calculated from the preceding digits. If a scanner misreads one bar, the arithmetic won’t come out, and the scanner rejects the read rather than returning the wrong product. It detects errors; it can’t correct them.

Using 0712345678911 as an example, with the final 1 being the check digit:

  1. Drop the check digit. Starting from the right, add every second digit: 1 + 8 + 6 + 4 + 2 + 7 = 28
  2. Multiply by three: 28 × 3 = 84
  3. Add the remaining digits: 0 + 1 + 3 + 5 + 7 + 9 = 25
  4. Add the results of steps 2 and 3: 84 + 25 = 109
  5. The check digit is whatever it takes to get that to the next multiple of ten. 109 + 1 = 110, so the check digit is 1.

The same method works for a 12-digit UPC-A. Run it on 712345678911 (the UPC-A version of the same number), and you get 1 again, because the leading zero adds nothing to the sum.

You don’t have to do this by hand. Our GTIN Validator checks any UPC, EAN, or ITF-14 number in seconds.

How the bars encode the digitsEAN code

Each digit is drawn as two black bars and two white spaces. The widths distinguish one digit from another; it’s the pattern of widths the scanner measures, not the numerals printed underneath.

There are three encoding schemes, usually written L, G and R:

  • UPC-A uses L for the left six digits and R for the right six.
  • EAN-13 uses R for the right six, and a mixture of L and G for the left six.

Because every barcode starts with an L or G digit and ends with an R digit, a scanner can tell which end it’s looking at. That’s why scanning a product upside down works.

Why the 13th digit isn’t in the bars

An EAN-13 has thirteen digits but only twelve digit patterns. The first digit isn’t drawn at all.

Instead, it’s carried by the pattern of L and G encoding across the left-hand six digits. There are ten possible L/G combinations, one for each value the first digit can take, so a scanner reads the parity sequence and infers the L/G combination.

This is also why a UPC-A and an EAN-13 of the same number produce identical bars. When the leading digit is zero, the pattern is all-L — exactly what a UPC-A uses. The bars are the same drawing; only the placement of the printed digits differs. More on that comparison.


Buy retail barcodes. UPC-A and EAN-13 images are supplied with every number.