code-128
EAN-13

code-128
EAN-13

Let's barcode is a free online tool to generate barcodes. Two barcode types are supported: EAN13 and Code128.
Please click the question to see the answer.

What is barcode?

It is a string of signs encoded as black and white stripes. Those signs are first converted to binary (0 and 1). Then 0 is prsented as white bar and 1 as black one.

What is EAN13?

EAN13 is a thirteen digits number used to identify products.

How to get EAN13 code for a product?

Please contacts GS1.

What is Code128?

Code128 is a standard created to encode ASCII sings. You can use this to encode data, that you would like to read by a scaner.

How to create list of barcodes?

Prepare file with codes. Each code for each line. Then go to FileImport and put the file into the form.

How is EAN13 created?

This code contains thirteen digist. Last one is a control number calculated as ten minus the rest of division:

(digit[1] + 3 * digit[2] + digit[3] + 3 * digit[4] + digit[5] + 3 * digit[6] + digit[7] + 3 * digit[8] + digit[9] + 3 * digit[10] + digit[11] + 3 * digit[12]) by 10. For examle for code 123456789012 it is (1 + 3*2 + 3 + 3*4 + 5 + 3*6 + 7 + 3*8 + 9 +3*0 + 1 + 3*2) = 162. 162%10 = 2 and 10 - 2 = 8 (when rest of division is 0 we use 0), so eight is a control digit and a whole code is 1234567890128. Every time you use Let's barcode to generate EAN13 code, if thirteen digit is different than control number, it is replaced by it.

Next step is to convert those digits into string of one and zero. There are three dictionaries. Let's call them L, G and R. And so:

L contains [0001101,0011001,0010011,0111101,0100011,0110001,0101111,0111011,0110111,0001011] - first is for 0, next for 1 then for 2 and so on. G is [0100111,0110011,0011011,0100001,0011101,0111001,0000101,0010001,0001001,0010111]

R: [1110010,1100110,1101100,1000010,1011100,1001110,1010000,1000100,1001000,1110100].

Everytime we start our code with 101. Then we use L dictionary to represent the second digit of the code (the second, not the first). In our case it is 0010011. Now it is time for then third digit. The dictionary depends on first digit. If it is smaller than four, we use L dictionary. In other cases we use G. So here we have on the first digit 1, so let's use L and for three and it would be 0111101.

The fourth digits dictionary also depends on the first one. And it is so till the seventh. We use L for the fourth digit if first one is one of (0, 4, 7, 8), else we use G. Here we have to use G because 1 is none of (0, 4, 7, 8) and for four we use 0011101.

Next digits works the same way. We use L: for the fifth digit is the first is in (0, 1, 4, 5, 9)

for the sixth digit is the first is in (0, 2, 5, 6, 7)

for the seventh digit is the first is in (0, 3, 6, 8, 9)

In other cases we use G dictionary. As our first digit is one, we use L for the fifth and G for sixth and seventh: 0110001, 0000101, 0010001.

In this place we are in the middle of the code and we have to paste: 01010.

For the rest of the digits whe use R dictionary. 8 means 1001000, 9 - 1110100, 0 - 1110010, 1 - 1100110, 2 - 1101100, 8 - 1001000. < br/> Finaly we add 101 to the code and that's it. Our code is now string of 95 digits (0 and 1):

**101** 0010011 0111101 0011101 0110001 0000101 0010001 **01010** 1001000 1110100 1110010 1100110 1101100 1001000 **101**.
Now we can start draw our code. For 1 we make black bar and white for 0. For bold digits bars should be longer. Finaly the code is:

(digit[1] + 3 * digit[2] + digit[3] + 3 * digit[4] + digit[5] + 3 * digit[6] + digit[7] + 3 * digit[8] + digit[9] + 3 * digit[10] + digit[11] + 3 * digit[12]) by 10. For examle for code 123456789012 it is (1 + 3*2 + 3 + 3*4 + 5 + 3*6 + 7 + 3*8 + 9 +3*0 + 1 + 3*2) = 162. 162%10 = 2 and 10 - 2 = 8 (when rest of division is 0 we use 0), so eight is a control digit and a whole code is 1234567890128. Every time you use Let's barcode to generate EAN13 code, if thirteen digit is different than control number, it is replaced by it.

Next step is to convert those digits into string of one and zero. There are three dictionaries. Let's call them L, G and R. And so:

L contains [0001101,0011001,0010011,0111101,0100011,0110001,0101111,0111011,0110111,0001011] - first is for 0, next for 1 then for 2 and so on. G is [0100111,0110011,0011011,0100001,0011101,0111001,0000101,0010001,0001001,0010111]

R: [1110010,1100110,1101100,1000010,1011100,1001110,1010000,1000100,1001000,1110100].

Everytime we start our code with 101. Then we use L dictionary to represent the second digit of the code (the second, not the first). In our case it is 0010011. Now it is time for then third digit. The dictionary depends on first digit. If it is smaller than four, we use L dictionary. In other cases we use G. So here we have on the first digit 1, so let's use L and for three and it would be 0111101.

The fourth digits dictionary also depends on the first one. And it is so till the seventh. We use L for the fourth digit if first one is one of (0, 4, 7, 8), else we use G. Here we have to use G because 1 is none of (0, 4, 7, 8) and for four we use 0011101.

Next digits works the same way. We use L: for the fifth digit is the first is in (0, 1, 4, 5, 9)

for the sixth digit is the first is in (0, 2, 5, 6, 7)

for the seventh digit is the first is in (0, 3, 6, 8, 9)

In other cases we use G dictionary. As our first digit is one, we use L for the fifth and G for sixth and seventh: 0110001, 0000101, 0010001.

In this place we are in the middle of the code and we have to paste: 01010.

For the rest of the digits whe use R dictionary. 8 means 1001000, 9 - 1110100, 0 - 1110010, 1 - 1100110, 2 - 1101100, 8 - 1001000. < br/> Finaly we add 101 to the code and that's it. Our code is now string of 95 digits (0 and 1):

How is Code128 created?

This is a bit simplified descpription, but usable in most cases.

There are three dictionaries: A, B and C (in the table below). According to the signs in our code we shoud choose dictionary. For example if we have only digits, the C would be good one. If we have some lowercase, let's choose B. And if our code contains white signs, then use A. The is always posibility to switch the dictionary. We start our encoded code according to choosen set:

A is 11010000100 (103)

B - 11010010000 (104)

C - 11010011100 (105)

then look for encoded value for each sing (or pair of signs if we use C) is our dictionary. If there is no code for our sing, we have to switch dictionary.

Use 10111011110 (99) to switch to C

, 10111101110 (100) to switch to B

, 11101011110 (101) to switch to A

When we encode every sign, we should add control number. We sum our start number (in brackets), and then for each sign (or pair of sings if C was choosen) its order no multiplied by position no. Then we take rest of division our result by 103, and use encoded value for it. Finaly we finish the code with 1100011101011.

For example we encode 1234567Ab. We may encode it with every dictionary, but let's start it with C, so:

We start with 11010011100 and we add to our control no. sum 105.

On the first position there is 12. We take 10110011100 and we add 12 * 1 to control no. sum.

On the second position we have 23. We take 11101101110 and we add 23 * 2 to control no. sum.

Next is 56. This means 11100010110 and 56 * 3 to control no sum.

For 7 we have to switch to A or B. For B we use 10111101110 and 100 * 4 to control no sum. Now we look for code for 7 in B dictionary. It has 23 order no. and it is 11101101110. Our control sum encrease by 23 * 5.

Finaly for A and b we have 10100011000 and 10010000110. To Control number sum we add 6 * 33 and 7 * 66.

Let's calculate control no.: 105 + 12*1 + 23*2 + 56*3 + 100*4 + 23*5 + 33*6 + 66*7 = 1506. The rest of division by 103 is 11 for each we use 11000100100. Our code is ready:

11010011100 10110011100 11101101110 11100010110 10111101110 11101101110 10100011000 10010000110 11000100100 1100011101011

This barcode coreated in our serive would be a bit different, because our algorithm will start it with B. Scanners read both codes the same. The code is then:

11010010000 10011100110 11001110010 11001011100 11001001110 11011100100 11001110100 11101101110 10100011000 10010000110 10001001100 1100011101011

There are three dictionaries: A, B and C (in the table below). According to the signs in our code we shoud choose dictionary. For example if we have only digits, the C would be good one. If we have some lowercase, let's choose B. And if our code contains white signs, then use A. The is always posibility to switch the dictionary. We start our encoded code according to choosen set:

A is 11010000100 (103)

B - 11010010000 (104)

C - 11010011100 (105)

then look for encoded value for each sing (or pair of signs if we use C) is our dictionary. If there is no code for our sing, we have to switch dictionary.

Use 10111011110 (99) to switch to C

, 10111101110 (100) to switch to B

, 11101011110 (101) to switch to A

When we encode every sign, we should add control number. We sum our start number (in brackets), and then for each sign (or pair of sings if C was choosen) its order no multiplied by position no. Then we take rest of division our result by 103, and use encoded value for it. Finaly we finish the code with 1100011101011.

For example we encode 1234567Ab. We may encode it with every dictionary, but let's start it with C, so:

We start with 11010011100 and we add to our control no. sum 105.

On the first position there is 12. We take 10110011100 and we add 12 * 1 to control no. sum.

On the second position we have 23. We take 11101101110 and we add 23 * 2 to control no. sum.

Next is 56. This means 11100010110 and 56 * 3 to control no sum.

For 7 we have to switch to A or B. For B we use 10111101110 and 100 * 4 to control no sum. Now we look for code for 7 in B dictionary. It has 23 order no. and it is 11101101110. Our control sum encrease by 23 * 5.

Finaly for A and b we have 10100011000 and 10010000110. To Control number sum we add 6 * 33 and 7 * 66.

Let's calculate control no.: 105 + 12*1 + 23*2 + 56*3 + 100*4 + 23*5 + 33*6 + 66*7 = 1506. The rest of division by 103 is 11 for each we use 11000100100. Our code is ready:

11010011100 10110011100 11101101110 11100010110 10111101110 11101101110 10100011000 10010000110 11000100100 1100011101011

This barcode coreated in our serive would be a bit different, because our algorithm will start it with B. Scanners read both codes the same. The code is then:

11010010000 10011100110 11001110010 11001011100 11001001110 11011100100 11001110100 11101101110 10100011000 10010000110 10001001100 1100011101011

Order no. | Encoded | A | B | C |
---|---|---|---|---|

0 | 11011001100 | space | space | 00 |

1 | 11001101100 | ! | ! | 01 |

2 | 11001100110 | " | " | 02 |

3 | 10010011000 | # | # | 03 |

4 | 10010001100 | $ | $ | 04 |

5 | 10001001100 | % | % | 05 |

6 | 10011001000 | & | & | 06 |

7 | 10011000100 | ' | ' | 07 |

8 | 10001100100 | ( | ( | 08 |

9 | 11001001000 | ) | ) | 09 |

10 | 11001000100 | * | * | 10 |

11 | 11000100100 | + | + | 11 |

12 | 10110011100 | , | , | 12 |

13 | 10011011100 | - | - | 13 |

14 | 10011001110 | . | . | 14 |

15 | 10111001100 | / | / | 15 |

16 | 10011101100 | 0 | 0 | 16 |

17 | 10011100110 | 1 | 1 | 17 |

18 | 11001110010 | 2 | 2 | 18 |

19 | 11001011100 | 3 | 3 | 19 |

20 | 11001001110 | 4 | 4 | 20 |

21 | 11011100100 | 5 | 5 | 21 |

22 | 11001110100 | 6 | 6 | 22 |

23 | 11101101110 | 7 | 7 | 23 |

24 | 11101001100 | 8 | 8 | 24 |

25 | 11100101100 | 9 | 9 | 25 |

26 | 11100100110 | : | : | 26 |

27 | 11101100100 | ; | ; | 27 |

28 | 11100110100 | < | < | 28 |

29 | 11100110010 | = | = | 29 |

30 | 11011011000 | > | > | 30 |

31 | 11011000110 | ? | ? | 31 |

32 | 11000110110 | @ | @ | 32 |

33 | 10100011000 | A | A | 33 |

34 | 10001011000 | B | B | 34 |

35 | 10001000110 | C | C | 35 |

36 | 10110001000 | D | D | 36 |

37 | 10001101000 | E | E | 37 |

38 | 10001100010 | F | F | 38 |

39 | 11010001000 | G | G | 39 |

40 | 11000101000 | H | H | 40 |

41 | 11000100010 | I | I | 41 |

42 | 10110111000 | J | J | 42 |

43 | 10110001110 | K | K | 43 |

44 | 10001101110 | L | L | 44 |

45 | 10111011000 | M | M | 45 |

46 | 10111000110 | N | N | 46 |

47 | 10001110110 | O | O | 47 |

48 | 11101110110 | P | P | 48 |

49 | 11010001110 | Q | Q | 49 |

50 | 11000101110 | R | R | 50 |

51 | 11011101000 | S | S | 51 |

52 | 11011100010 | T | T | 52 |

53 | 11011101110 | U | U | 53 |

54 | 11101011000 | V | V | 54 |

55 | 11101000110 | W | W | 55 |

56 | 11100010110 | X | X | 56 |

57 | 11101101000 | Y | Y | 57 |

58 | 11101100010 | Z | Z | 58 |

59 | 11100011010 | [ | [ | 59 |

60 | 11101111010 | \ | \ | 60 |

61 | 11001000010 | ] | ] | 61 |

62 | 11110001010 | ^ | ^ | 62 |

63 | 10100110000 | _ | _ | 63 |

64 | 10100001100 | NUL | ` | 64 |

65 | 10010110000 | SOH | a | 65 |

66 | 10010000110 | STX | b | 66 |

67 | 10000101100 | ETX | c | 67 |

68 | 10000100110 | EOT | d | 68 |

69 | 10110010000 | ENQ | e | 69 |

70 | 10110000100 | ACK | f | 70 |

71 | 10011010000 | BEL | g | 71 |

72 | 10011000010 | BS | h | 72 |

73 | 10000110100 | HT | i | 73 |

74 | 10000110010 | LF | j | 74 |

75 | 11000010010 | VT | k | 75 |

76 | 11001010000 | FF | l | 76 |

77 | 11110111010 | CR | m | 77 |

78 | 11000010100 | SO | n | 78 |

79 | 10001111010 | SI | o | 79 |

80 | 10100111100 | DLE | p | 80 |

81 | 10010111100 | DC1 | q | 81 |

82 | 10010011110 | DC2 | r | 82 |

83 | 10111100100 | DC3 | s | 83 |

84 | 10011110100 | DC4 | t | 84 |

85 | 10011110010 | NAK | u | 85 |

86 | 11110100100 | SYN | v | 86 |

87 | 11110010100 | ETB | w | 87 |

88 | 11110010010 | CAN | x | 88 |

89 | 11011011110 | EM | y | 89 |

90 | 11011110110 | SUB | z | 90 |

91 | 11110110110 | ESC | {{'{'}} | 91 |

92 | 10101111000 | FS | | | 92 |

93 | 10100011110 | GS | {{'}'}} | 93 |

94 | 10001011110 | RS | ~ | 94 |

95 | 10111101000 | US | DEL | 95 |

96 | 10111100010 | FNC 3 | FNC 3 | 96 |

97 | 11110101000 | FNC 2 | FNC 2 | 97 |

98 | 11110100010 | Shift B | Shift A | 98 |

99 | 10111011110 | Code C | Code C | 99 |

Other questions or issues.

Please contact us at