How the EAN-13 check digit works
The 13th digit of every EAN-13 barcode is not chosen — it is calculated. Here is the formula, a full worked example, and why it matters.
An EAN-13 barcode encodes thirteen digits. The first twelve identify the product (a GS1 prefix, a company prefix and an item reference); the thirteenth is a check digit — a single digit computed from the other twelve. Its only job is to catch errors: if one digit is mistyped or misread, the check digit no longer matches and the scan is rejected.
The formula, in plain terms
Reading the twelve data digits from left to right:
- Multiply the digits in odd positions (1st, 3rd, 5th …) by 1.
- Multiply the digits in even positions (2nd, 4th, 6th …) by 3.
- Add all the results together to get a sum.
- The check digit is whatever you must add to that sum to reach the next multiple of ten. In formula terms: check = (10 − (sum mod 10)) mod 10.
That final "mod 10" matters for one edge case: if the sum is already a multiple of ten, the check digit is 0, not 10.
A worked example
Take the twelve data digits 400638133393. Lay them out with their weights:
| Digit | 4 | 0 | 0 | 6 | 3 | 8 | 1 | 3 | 3 | 3 | 9 | 3 |
| Weight | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 | 1 | 3 |
| Product | 4 | 0 | 0 | 18 | 3 | 24 | 1 | 9 | 3 | 9 | 9 | 9 |
The products add up to 4 + 0 + 0 + 18 + 3 + 24 + 1 + 9 + 3 + 9 + 9 + 9 = 89. The next multiple of ten above 89 is 90, and 90 − 89 = 1. So the check digit is 1, and the complete EAN-13 is 4006381333931.
Why scanners rely on it
When a scanner reads an EAN-13, it repeats exactly this calculation on the first twelve digits and compares the result to the thirteenth. If they disagree, the read is discarded. This single extra digit catches the overwhelming majority of single-digit typos and many transposition errors — cheap insurance against scanning the wrong product at a checkout.
The same maths powers UPC, EAN-8 and GTIN-14
The EAN-13 method is really the GS1 modulo-10 algorithm, and it is shared across the family: UPC-A (11 data digits), EAN-8 (7 data digits) and GTIN-14 / ITF-14 (13 data digits) all use the same alternating weights of 3 and 1 from the right. Only the length changes; the logic is identical.