EAN-13 Encoding

Following the success of UPC-A encoding (1973), the EAN-13 format has been adopted in Europe by the International Article Numbering Association (EAN) in 1976. A twelve digit UPC-A is easily embedded into the 13 digit EAN-13 by prepending one 0 digit. The first 0 is indeed an EAN number system prefix indicating the USA (or Canada) as the country of origin. In general an EAN-code consists of four parts:

1. 2-3 digit Number System, or country code (with industrial counties assigned 2-digit codes and smaller or less developed countries assigned 3-digit codes.)
2. 5-4 digit Manufacturer (Company) Code or prefix. (The first two parts always use the first 7 digits.)
3. 5 digit Product Code.
4. 1 Check Digit.

In a barcode representation, the first of the 13 digits of an EAN code plays a peculiar role, whereas the remaining 12 are converted in two groups of six digits: left and right.

The country codes are naturally in public domain and available on Internet. One peculiarity is worth a mention: In order to embed the standard ISBN-10 into EAN-13, a country without borders (but also without territory) has been brought into play. The ISBN Bookland has received the country code of 978 so that, for example, an ISBN code 0-14-200057-4 is converted into EAN-13's 9780142000571. The difference in the last (check) digit is due to the difference of the applied algorithms.

The check digit algorithm in EAN-13 works almost in the same manner as in UPC-A. However, the twelfth digit, i.e. the one next to the check digit, is declared odd. All other odd digits are obtained from this one by moving leftward and counting each other digit. This is done in order to smoothly incorporate UPC-A as a whole without the need to modify its check digit.

Thus for a valid 13-digit EAN code d1d2d3...d13, we have

 (1) d1 + 3×d2 + d3 + 3×d4 + ... + d11 + 3×d12 + d13 = 0 (mod 10).

In the applet below, the first twelve digits of the code are clickable and modifiable. The last digit is calculated automatically according to (1).

If you are reading this, your browser is not set to run Java applets. Try IE11 or Safari and declare the site https:///www.cut-the-knot.org as trusted in the Java setup.

 What if applet does not run?