1. Introduction to the EAN-13 Check Digit
Across the globe—from supermarkets in Berlin and convenience stores in Tokyo to departmental stores in Mumbai and high-street boutiques in London—the 13-digit International Article Number (EAN-13) is the universal language of retail checkout. Just like its 12-digit American cousin (the UPC-A), every single EAN-13 barcode reserves its 13th digit as a cryptographic checksum.
When an EAN-13 barcode is printed on consumer packaging, an optical scanner must be able to read it instantaneously regardless of whether the cashier sweeps it forwards, backwards, or upside down. If a laser scanner misses a single line or if print toner flakes off a cereal box, the checkout register must never invent a fictitious product code. The modulo-10 algorithm behind the 13th digit guarantees that any single-digit alteration or numerical transposition halts the transaction with an error notification.
2. The Deep Mystery: Why EAN-13 Weights Even Positions by 3
If you have previously calculated a 12-digit UPC-A check digit (as detailed in our UPC-A Check Digit Tutorial), you will encounter an apparent contradiction that confuses many software developers and packaging engineers:
- In UPC-A (12 digits), the odd positions (1, 3, 5, 7, 9, 11) are multiplied by 3, while even positions are multiplied by 1.
- In EAN-13 (13 digits), the even positions (2, 4, 6, 8, 10, 12) are multiplied by 3, while odd positions are multiplied by 1.
Why did the GS1 architects reverse the rules? Did they make an arbitrary decision?
The answer lies in counting direction: GS1 calculates all check digits right-to-left!
In the unified GS1 General Specifications (which govern 8-digit EAN-8, 12-digit UPC-A, 13-digit EAN-13, and 14-digit ITF-14 carton barcodes), the check digit is always defined as Position 1 counting from right to left. Counting from right to left:
- The check digit itself is at Right Position 1 (Weight 1).
- The digit immediately to its left is at Right Position 2 (Weight 3).
- The next digit is at Right Position 3 (Weight 1).
- The next digit is at Right Position 4 (Weight 3)... and so forth in an alternating sequence (
..., 3, 1, 3, 1).
Now look at what happens when you compare 12-digit UPC-A against 13-digit EAN-13:
| Symbology | Total Digits | Left-to-Right Position 1 | Right-to-Left Position (from check digit) | Assigned GS1 Weight |
|---|---|---|---|---|
| UPC-A | 12 (Even number) | Position 1 (Odd) | Position 12 (Even from right) | Weight 3 |
| EAN-13 | 13 (Odd number) | Position 1 (Odd) | Position 13 (Odd from right) | Weight 1 |
Because EAN-13 has an odd number of total characters (13), counting backwards from the right lands Weight 3 on all even-numbered positions when viewed from the left! The mathematical principle is 100% consistent across both systems; the inversion is purely an optical consequence of adding one extra country-code digit to the left side of the barcode.
3. The 4-Step EAN-13 Algorithm Explained
To calculate the 13th digit of an EAN-13 barcode from its initial 12-digit payload, execute these four steps:
The 4-Step Calculation Rule:
- Step 1 (Sum Odd Positions): Add together all the digits located in the odd positions (positions 1, 3, 5, 7, 9, and 11) counting left-to-right. Multiply this sum by 1 (leave it as is).
- Step 2 (Sum Even Positions & Multiply by 3): Add together all the digits located in the even positions (positions 2, 4, 6, 8, 10, and 12). Multiply this resulting sum by 3.
- Step 3 (Combine Sums): Add the result of Step 1 to the result of Step 2 to obtain the total weighted sum.
- Step 4 (Determine Check Digit): Find the smallest integer that, when added to the total sum, rounds it up to the nearest multiple of 10.
Formula: \(\text{Check Digit} = (10 - (\text{Total Sum} \pmod{10})) \pmod{10}\).
If the total sum is already an exact multiple of 10, the check digit is 0.
4. Worked Mathematical Examples
Example 1: Indian FMCG Retail Item (Payload: 890103038345)
This payload represents a real consumer product licensed by GS1 India (prefix 890). Let’s find the 13th check digit:
- Step 1: Sum odd positions (1, 3, 5, 7, 9, 11):
Digits:8, 0, 0, 0, 8, 4
Sum:8 + 0 + 0 + 0 + 8 + 4 = 20.
Multiply by 1:20 × 1 = 20. - Step 2: Sum even positions (2, 4, 6, 8, 10, 12):
Digits:9, 1, 3, 3, 3, 5
Sum:9 + 1 + 3 + 3 + 3 + 5 = 24.
Multiply by 3:24 × 3 = 72. - Step 3: Total combined sum:
20 + 72 = 92. - Step 4: Next higher multiple of 10 is
100.
100 - 92 = 8.
Result: The 13th check digit is 8. The complete, legal EAN-13 barcode is8901030383458. (Verify this instantly on our EAN-13 Check Digit Calculator).
Example 2: British Retail Product (Payload: 501234567890)
This payload features the UK GS1 prefix 50:
- Step 1 (Odd Positions): Digits:
5, 1, 3, 5, 7, 9
Sum:5 + 1 + 3 + 5 + 7 + 9 = 30.
Multiply by 1:30. - Step 2 (Even Positions): Digits:
0, 2, 4, 6, 8, 0
Sum:0 + 2 + 4 + 6 + 8 + 0 = 20.
Multiply by 3:20 × 3 = 60. - Step 3: Combined total sum:
30 + 60 = 90.
Notice that 90 is already an exact multiple of 10! - Step 4: Check digit calculation:
90 - 90 = 0.
Result: The 13th digit is 0. The complete EAN-13 barcode is5012345678900.
Example 3: Bookland ISBN-13 (Payload: 978030640615)
Books utilize the global Bookland prefix 978 or 979:
- Step 1 (Odd Positions): Digits:
9, 8, 3, 6, 0, 1
Sum:9 + 8 + 3 + 6 + 0 + 1 = 27 × 1 = 27. - Step 2 (Even Positions): Digits:
7, 0, 0, 4, 6, 5
Sum:7 + 0 + 0 + 4 + 6 + 5 = 22 × 3 = 66. - Step 3: Combined total sum:
27 + 66 = 93. - Step 4: Next multiple of 10 is
100.
100 - 93 = 7.
Result: The 13th digit is 7. The published ISBN-13 is978-0-306-40615-7. (Generate author barcodes using our ISBN Barcode Generator).
5. Code Snippets: Excel, Python & JavaScript
Excel / Google Sheets Formula
Assuming your 12-digit EAN prefix is entered as a text string in cell A2:
Python 3 Implementation
Frequently Asked Questions
Why does EAN-13 multiply even positions by 3 while UPC-A multiplies odd positions by 3?
In the global GS1 system, positions are mathematically weighted right-to-left starting from the check digit position with weight 1, then alternating 3, 1, 3... Because EAN-13 has 13 total digits (an odd number of digits), counting right-to-left results in even-numbered positions (when viewed left-to-right) receiving the weight 3 multiplier. In UPC-A (12 total digits), counting right-to-left results in odd-numbered positions receiving the weight 3 multiplier. The underlying logic is mathematically identical.
What is the check digit formula for EAN-13 in Excel?
If cell A2 contains your 12-digit prefix, use: =MOD(10 - MOD((MID(A2,1,1)+MID(A2,3,1)+MID(A2,5,1)+MID(A2,7,1)+MID(A2,9,1)+MID(A2,11,1)) + (MID(A2,2,1)+MID(A2,4,1)+MID(A2,6,1)+MID(A2,8,1)+MID(A2,10,1)+MID(A2,12,1))*3, 10), 10).
What happens if the calculated checksum equals 10?
If the intermediate sum is a multiple of 10 (e.g. 80, 90, 100), the check digit is 0. A check digit can only be a single digit between 0 and 9.
Is the check digit for Indian EAN-13 barcodes calculated differently?
No. Indian retail barcodes (starting with the official GS1 India prefix 890) follow the exact same international ISO/IEC and GS1 modulo-10 checksum algorithm as European, British, or Japanese EAN-13 barcodes.