Home/Encoding Knowledge/Barcode Basics/EAN-13 check digit algorithm
Barcode Basics · 4 min read
Barcode BasicsContent reviewed

How is the EAN-13 check digit calculated

The first 12 digits are alternately weighted and summed as "1, 3, 1, 3...", and the complement of the result to 10 is taken—that is how the check digit is derived. It does not guarantee the product is genuine, but it can block the vast majority of entry and printing errors.

Executive summary:This article demonstrates step by step the mod10 calculation process for the EAN-13 check digit, explains why the weighting order is "1, 3" rather than "3, 1", and what passing verification really means and does not mean. At the end, an online tool can be used to recalculate any number.
01

Step 1: Alternately weight the first 12 digits

EAN-13 has 13 digits in total; the last digit is the check digit, and the first 12 digits are data digits. When calculating, start from the 1st digit: odd positions (1st, 3rd, 5th... digits) are multiplied by 1, even positions (2nd, 4th, 6th... digits) are multiplied by 3, and then the 12 products are added together. Note: count from the first digit on the left, not from the right.

02

Step 2: Calculate the complement to get the check digit

Take the sum from the previous step modulo 10, then subtract this remainder from 10, and take the result modulo 10 again—the resulting single digit is the check digit. The formula is written as (10 − sum mod 10) mod 10; the final mod is applied again to handle the case where the remainder is 0 and the result would be 10.

03

Why the weights are 1 and 3

The alternating 1/3 weighting design makes adjacent positions have different weights, so the most common human error of "two adjacent digits reversed" (such as 12 read as 21) almost certainly changes the weighted sum and is therefore caught by the check digit. This is the core purpose of check digit design: not encryption, but error detection.

04

What passing the check means

It means only one thing: the composition of this string of digits is valid, that is, it could indeed be a GTIN generated according to the rules. Itdoes notmean that this number has been assigned to an enterprise,does notmean that the product is genuine, nordoes notmean that the number exists in the GS1 database. To confirm ownership, you need to check the registration information of the member organization; to determine authenticity, you need the brand owner's anti-counterfeiting measures. This is where many articles get confused.

Key points at a glance

Key conclusions that can be excerpted directly.

Point 01

The three core sentences of the algorithm

From the left, odd positions ×1, even positions ×3, sum them, and take (10 − sum mod 10) mod 10.

Point 02

The weighting design guards against transposition errors

Adjacent positions have different weights, leaving high-frequency errors such as "digits written in reverse" nowhere to hide.

Point 03

Passing the check ≠ valid number

A legal format only means it may be legal; it does not mean it has been assigned, nor that the product is genuine.

Key Point 04

Manually filling in the check digit is a high-risk action

If it is wrong, it cannot be scanned, and if it enters the printing process, it will cause the entire batch of packaging to be scrapped.

Data Comparison

PositionDigitWeightProduct
1616
29327
3010
4133
5212
6339
7414
85315
9616
107321
11818
129327
Total——128
Complement (10 − 128 mod 10) mod 10——2

Illustration

EAN-13 check digit demonstration

EAN-13 check digit demonstrationReal barcode rendering
6901234567892

The example 690123456789 uses the first 12 digits for demonstration; the check digit is derived by the algorithm, and the resulting number does not belong to any company.

Terminology explanation

The proper nouns involved in this article.

mod10

Modulo 10 operation, taking the remainder after division by 10. GS1 series check digits are all based on mod10.

Weighted sum

The sum of each digit multiplied by its respective weight, an intermediate value in the check calculation.

Transposition error

Two adjacent digits written in reversed order, one of the most frequent types of manual entry errors.

Related Q&A

I calculated 10, what should I do?+
This situation will not occur in a correct result—the mod 10 at the end of the formula reduces 10 to zero. If you manually calculate 10, check whether you missed the final remainder step.
Is the algorithm for UPC-A the same?+
The structure is the same, but the weighting order is reversed: for UPC-A, odd positions from the left are multiplied by 3 and even positions by 1. This is also why the same barcode yields different results under different algorithms.
Can the check digit be filled in arbitrarily?+
No. The check digit is a function of the data digits; if any data digit is changed, the check digit must be recalculated. After the number arrangement is completed, it should be batch-verified with a tool before delivery for printing.
Do I have to go through an agent for this?+
It is not mandatory. You can apply directly to the corresponding member organization; the value of an agent lies in selecting the number range, arranging the numbers, checking materials, and managing the continuity of subsequent changes and renewals. Whether to entrust this depends on your time cost.
Can the numbers in the content be used directly?+
The barcodes appearing in the text are all demonstration numbers generated according to GS1 rules. The structure is valid, but they do not belong to any company. Do not use them directly for real products; official codes must be arranged by yourself according to the code segment obtained through registration.
How long until I get a result?+
Acceptance periods vary among member organizations. This site does not provide unconfirmed commitments regarding the number of days. After you submit your request, a coding consultant will update the milestones according to the current acceptance progress.

Authoritative sources and notes

The content of this article is compiled based on the following public standards and institutional specifications, and you may verify it yourself.

Source 01

GS1 General Specifications

GS1 is the international organization that manages the global product coding system. Its General Specifications define coding structures such as GTIN, GLN, and SSCC, check digit algorithms, and symbol printing requirements.

Source 02

Open-source decoder ecosystem (ZXing / zxing-cpp / zbar)

All barcode examples on this site have been verified by reading back with open-source decoders, so you can check them yourself and avoid illustrations that "look right but cannot be scanned."

Content statement:This article is a general explanation of coding knowledge and does not contain any specific amounts, day commitments, or regulatory clause numbers; for current requirements of specific markets and platforms, please refer to the official documents of the corresponding institutions and platforms. All barcodes appearing in this article are demonstration numbers generated according to GS1 rules, do not belong to any company, and must not be used for real products.

Related Articles

Still have specific questions after reading?

Knowledge pages address general questions. When it comes to your specific products, markets, and channels, it is faster to ask a coding consultant directly.

—