Tool to generate / decode EAN-13 barcodes. The EAN13 code (European Article Numbering 13) is a barcode standard (European then International) used for commercial products.
Barcode EAN13 - dCode
Tag(s) : Character Encoding, Image Processing
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
The EAN-13 Barcode format is the most widely used product barcode format. It codes 13-digit numbers via 7-bit binary codes using three correspondence tables:
Digit | Left 1 Odd | Left 2 Even | Right |
---|---|---|---|
0 | 0001101 | 0100111 | 1110010 |
1 | 0011001 | 0110011 | 1100110 |
2 | 0010011 | 0011011 | 1101100 |
3 | 0111101 | 0100001 | 1000010 |
4 | 0100011 | 0011101 | 1011100 |
5 | 0110001 | 0111001 | 1001110 |
6 | 0101111 | 0000101 | 1010000 |
7 | 0111011 | 0010001 | 1000100 |
8 | 0110111 | 0001001 | 1001000 |
9 | 0001011 | 0010111 | 1110100 |
The first step is to locate the first digit of the barcode which will define a coding table for the parities of the following 6 numbers. This first digit will not itself be coded.
First digit | Parities (1=add,2=even) |
---|---|
0 | 1,1,1,1,1,1 |
1 | 1,1,2,1,2,2 |
2 | 1,1,2,2,1,2 |
3 | 1,1,2,2,2,1 |
4 | 1,2,1,1,2,2 |
5 | 1,2,2,1,1,2 |
6 | 1,2,2,2,1,1 |
7 | 1,2,1,2,1,2 |
8 | 1,2,1,2,2,1 |
9 | 1,2,2,1,2,1 |
Example: In the barcode 3-456789-543219, the first digit is 3 so the parities to be used are 1,1,2,2,2,1.
To code the digits in positions 2 to 7 (on the left), use the binary codes left and the parity indicated by the coding table.
Example: The digits on the left 4,5,6,7,8,9 are coded with the parities 1,1,2,2,2,1 in EAN-13 (0 = empty and 1 = black bar) :
4 | 5 | 6 | 7 | 8 | 9 |
1 | 1 | 2 | 2 | 2 | 1 |
0100011 | 0110001 | 0000101 | 0010001 | 0001001 | 0001011 |
To code the digits in positions 8 to 13 (right), use the binary codes right .
Example: The figures on the right 543219 are coded in EAN-13 (0 = empty and 1 = black bar):
5 | 4 | 3 | 2 | 1 | 9 |
1001110 | 1011100 | 1000010 | 1101100 | 1100110 | 1110100 |
A complete EAN13 barcode begins and ends with a normal guard zone coded 101 and contains a central guard zone coded 01010 which separates the first 6 digits of the next 6.
Example: The number 3-456789-543219 is coded in EAN-13 (0 = empty and 1 = black bar):
|| | 3 | 456789 | || | 543219 | || |
101 | 0100011...0001011 | 01010 | 1001110...1110100 | 101 |
The 13th digit of the EAN-13 barcode is a checksum.
The decryption of the EAN13 code is done by binary reading of the black 1 and white 0 bands, which can then be translated via the coding tables (above).
The 12 coded digits can then be read, but the first digit is missing. To find out, note the parity found (even or odd left) of the first 6 digits and deduce the corresponding digit in the parity coding table.
Example: odd,even,odd,even,even,odd (or 1,2,1,2,2,1) corresponds to the number 8
The checksum is calculated with weights (1 and 3) associated with the first 12 digits of the bar code. The 13th digit (control character) is the digit $ x $ that must be added to the value found so that the total sum modulo 10 is 0.
Example: 012345678910 has the sum $ 0\times1+1\times3+2\times1+ \cdots +8\times1+9\times3+1\times1+0\times3=96 $ and $ 96 + X \equiv 0 \mod 10 \iff x = 4 $ so the check digit is 4
EAN13 has a graphical representation of a classic barcode (black bars on a white background), with generally 3 slightly longer double bars positioned at the beginning, in the middle and at the end.
An EAN13 barcode is made to code only 13-digit numbers, it is dedicated to everyday consumer products of supermarkets, food and non-food.
The binary representation of EAN-13 (with 0 or N for black and 1 or B for white lines) has a fixed length of 95 bits. It begins and terminates with 101 and never includes 5 identical consecutive bits.
dCode retains ownership of the "Barcode EAN13" source code. Except explicit open source licence (indicated Creative Commons / free), the "Barcode EAN13" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Barcode EAN13" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Barcode EAN13" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!
Reminder : dCode is free to use.
The copy-paste of the page "Barcode EAN13" or any of its results, is allowed (even for commercial purposes) as long as you credit dCode!
Exporting results as a .csv or .txt file is free by clicking on the export icon
Cite as source (bibliography):
Barcode EAN13 on dCode.fr [online website], retrieved on 2024-11-05,