Skip to content
ScanHatch

Barcodes

Barcode Check Digits Explained, With Worked Examples

By ScanHatch · Published · 5 min read

The last digit of most product barcodes isn't part of the product number. It's a check digit, calculated from all the other digits so that a scanner or a person typing the number can tell when something has gone wrong. This guide shows exactly how the common ones are calculated.

Why check digits exist

Scanners occasionally misread a bar, and people often mistype numbers. Without a check, a wrong number could look perfectly valid and be recorded against the wrong product. A check digit is a small calculation over the other digits. If any digit changes, the calculation usually no longer matches, and the error is caught.

The GS1 mod 10 check digit (EAN, UPC, ITF-14)

EAN-13, EAN-8, UPC-A and ITF-14 (and GTINs in general) share one method:

  1. Take all the digits except the check digit.
  2. Starting from the rightmost of them and moving left, multiply the digits alternately by 3 and 1.
  3. Add up the results.
  4. The check digit is the amount needed to reach the next multiple of 10 (0 if the total is already a multiple of 10).
Worked example: EAN-13 4006381333931
Digit400638133393
Weight131313131313
Product40018324193999

The products add up to 89. The next multiple of 10 is 90, so the check digit is 90 − 89 = 1, and the complete number is 4006381333931. Because the weights are anchored at the right-hand end, the same rule works for 8, 12, 13 and 14-digit numbers. The check digit calculator shows this table for any number.

UPC-E: expand first

A UPC-E code is a compressed UPC-A, so its check digit is calculated from the expanded 12-digit form. UPC-E 0425261 expands to UPC-A 04210000526, whose check digit is 4, so the UPC-E is 04252614. The EAN/UPC validator includes a converter that does the expansion.

ITF-14: a new check digit for each pack

Turning a product's GTIN-13 into a carton's GTIN-14 adds an indicator digit at the front, which changes the calculation. GTIN-13 5012345678900 packed in cases becomes GTIN-14 15012345678907: same 12 middle digits, different check digit. The ITF-14 validator calculates it for you.

What the GS1 check digit catches

  • Every error where a single digit is wrong.
  • Most swaps of two neighbouring digits: 80 of the 90 possible swaps are detected.
  • It misses swaps of two digits that differ by exactly 5, such as 1 and 6 or 3 and 8, because 3a + b and 3b + a then leave the same remainder.
  • Some multiple errors cancel out, so it isn't proof that a number is right. It only shows the number is internally consistent.

Note: A correct check digit doesn't mean a number is registered or belongs to any product. Registration is a separate matter handled by GS1.

Other check methods

Code 39: mod 43 (optional)

Each Code 39 character has a value from 0 to 42 (digits 0–9, then A = 10 up to Z = 35, then - . space $ / + %). Add the values and take the remainder after dividing by 43; the character with that value is the check character. For CODE39 the values are 12 + 24 + 13 + 14 + 3 + 9 = 75, and 75 mod 43 = 32, which is W, so the barcode would encode CODE39W. Many Code 39 systems don't use a check character at all.

Code 128: mod 103 (always present)

Code 128 always includes a check character, calculated from the start code's value plus each character's value multiplied by its position. For ABC in character set B: 104 (start B) + 33×1 + 34×2 + 35×3 = 310, and 310 mod 103 = 1, which is the character “!”. Scanners verify and remove it, so it never appears in the scanned text. What is Code 128? covers the format in detail.

ISBN-10: mod 11

Old 10-digit ISBNs weight the digits 10, 9, 8 … 1 and require the total to be divisible by 11. A remainder that would need 10 is written as X, which is why some ISBNs end in X. Mod 11 catches every single-digit error and every swap of neighbouring digits, but needs that extra symbol. Books now use 13-digit ISBNs with the GS1 method instead.

MSI: mod 10 and mod 11 variants

MSI (Modified Plessey) supports several schemes, including a mod 10 similar to the Luhn check used on payment cards, a mod 11, and doubled versions. The scheme must match what the scanner is set to expect.

Checking a number

The Barcode Validator checks the structure and check digit of 12 formats and explains exactly which rule passes or fails. The Barcode Generator adds the check digit when you enter a number without it, and tells you when it does.

Frequently asked questions

Can the check digit be 0?

Yes. When the weighted total is already a multiple of 10, the check digit is 0.

If the check digit is right, is the barcode number valid?

It's internally consistent, but that doesn't mean it's registered or assigned to a product.

Do all barcodes have a check digit?

No. Plain ITF, Codabar and Pharmacode have none, and Code 39's is optional.