UPC EAN Information

UPC-A Bar Code

The UPC-A bar code is used to encode a product GTIN-12 number into a machine readable form.

The GTIN system is the global standard for trade item numbers.

In this document I will describe in detail how the UPC-A bar code works. I’ll do this by taking an example of a GTIN-12 code. A product’s GTIN-12 is the item number that underlies the bar code that the product carries. The UPC-A bar code is simply a machine-readable way to represent the underlying product number.

Before we get to the product number, we need to understand the basic framework that underlies the UPC-A bar code. The diagram below shows the parts of a UPC-A bar code that are common to every instance.

UPC bar code framework

In the diagram above you can see three sets of what are called ‘guard bars’, and from left to right are known as the ‘start guard bars’, ‘centre guard bars’ and ‘stop guard bars’ respectively. Additionally there are two blank ‘quiet zones’, one to the left of the the start guard bars and one to the right of the stop guard bars where nothing extraneous to the bar code should be printed. In the UPC-A these quiet zones at the normal bar code size are each 2.97mm in width.

If you look carefully, you can see that both the start and stop bars each comprises three bars - two black bars sandwiching a white bar, all of them very thin. At first glance the centre guard may look the same, but it isn’t - they’re all very thin bars, but there are five of them, two white bars outside of two black black bars, and all ouitside of a third white bar.

None of those bars encode the data of our product number. They form a framework of two areas to hold the encoded product code, the first six characters of it in the left-hand section and the remaining six in the right. We can now get on and encode the product data, the GTIN-12.

The product that I have chosen for the example is a 142ml bottle of Encona West Indian Original Hot Pepper Sauce and available in the USA. The GTIN-12 for this product is 055270839959. Count up the digits, you will find there are 12.

We are going to take the GTIN and build the bar code from it, bit by bit. You will get all of the detail as we go, but it’s quite straightforward.

Like most things to do with computers, everything comes down to zeros and ones. The UPC-A is no exception.

Take the 12 digits and split them down the middle into two sets of six. Our GTIN splits into the first set of six of 055270, and the second set of 839959. The first set of six becomes encoded into the left-hand half of the UPC-A bar code, and the second six beome the right-hand half of the bar code, all inside of the framework just described.

Each character of the GTIN is translated into a sequence of 7 binary digits. So the first six become 42 (6 x 7) binary digits, as does the second six.

To convert each character of the GTIN, a table of values is used to covert a character to its binary code. There are two separate tables. One table is used for each of the left-hand six characters and a second table is used for the right-hand six characters. The two tables are different but related as we shall soon see.

Take the left-hand six characters 055270 and look-up each one in Table 1 below.

UPC-A Encoding Characters 1 to 6
GTIN Character Binary Code
0 0001101
1 0011001
2 0010011
3 0111101
4 0100011
5 0110001
6 0101111
7 0111011
8 0110111
9 0001011

Table 1: Encoding left-hand six characters of a GTIN-12

Before we encode our characters, please notice that each of the binary codes is seven digits long and starts with a zero and ends with a one.

Here are our first six product code characters and their binary codes.

0 is 0001101
5 is 0110001
5 is 0110001
2 is 0010011
7 is 0111011
0 is 0001101

Now join the binary codes together one after the other and we get:

000110101100010110001001001101110110001101

That long string of binary digits form the bars in the left half of the bar code. Each zero

If we turn our 1s into black blobs and our 0s into white blobs we get:

UPC binary encoding of characters in product code

Now if we extend the blobs in a vertical direction and show that pattern of blobs again as proper bar code bars it looks as we might expect.

UPC bar code - the left section data bars

When we fit that into the UPC-A bar code framework, this is what it looks like.

UPC bar code - the left section data bars fitted into the bar code framework

That’s the left-hand bit done. That wasn’t too difficult, was it? We’re nearly done! Just the right section to do.

There are some basic principles of the EAN-A to get to grips with and a few things to notice.

Principle 1: The thinnest bar is called the module size or x-width.

At the normal recommended size of an EAN-A bar code, one module equals 0.33 millimeters.

The next thickest is twice the thickness of the first - two modules. The width of the third thickest is three modules, and the widest is four modules.

The whole UPC bar code is a set number of modules wide. That number turns out to be 95 plus an additional nine modules both to the left and right of the bar code as a quiet zone where nothing should be printed.

Principle 2: A binary ‘one’ (1) results in a black bar of one module width and a binary zero (0) results in a white bar of one module width.

Where 2, 3 or 4 binary ones appear next to each other the separate one module wide bars adjacent to teach other appear to become a single wider bar of 2, 3 or 4 modules width. The same thing happens when 2, 3 or 4 binary zeros become single wider white bars.

In the encoding system where a product code character is encoded to 7 binary digits, you’ve already seen how all of the encodings in the table for the left half begin with a binary zero and end with a binary one. Notice now that all of the encodings each create four bars of varying width - a white bar to start, then a black bar, followed by another white bar and ending with a second black bar. For example, taking the encoding for the zero, the binary code is 0001101 which gives a white bar of 3 modules followed by a black bar of 2 modules, then a white bar of 1 module,and lastly a black bar of one module. The table is arranged to create four possible bar widths - 1 module, 2 modules, 3 modules or 4 modules.

The right-hand data section is made in the same way as the left, but a different table is used. Take a look at it below and compare it to the table for the left characters above. It is just the same, except that every zero is now a one, and vice versa.

UPC-A Encoding For Characters 6 to 12
GTIN Character Binary Code
0 1110010
1 1100110
2 1101100
3 1000010
4 1011100
5 1001110
6 1010000
7 1000100
8 1001000
9 1110100

Table 1: Encoding the last six characters of a GTIN-12

So let’s take the final 6 digits of our GTIN-12 and encode them using the table.

Our 6 digits are 839959

8 is 1001000
3 is 1000010
9 is 1110100
9 is 1110100
5 is 1001110
9 is 1110100

Join them all together one after the other and we get:

100100010000101110100111010010011101110100

When we turn our 1s into black blobs and our 0s into white blobs we get:

UPC binary encoding of characters in product code

Now if we show that again as proper bar code bars it looks as we might expect.

UPC bar code - the right section data bars

When we fit that into the UPC-A bar code framework into the right hand data section, this is what it looks like.

UPC bar code - the right section data bars fitted into the bar code framework

That’s all of the data done. We just need to add the human-readable version of the iem number to complete our UPC-A bar code.

Complete UPC bar code

UPC-A Bar Code Specifications

There are some specifications about sizes that you need to be aware of.

Standard dimensions are given for various UPC-A bar code factors. There should be a quiet zone or light margin with nothing printed in it to the left and right of the UPC-A bar code. This is so that the bar code scanner and the bar code software is able to determine where the UPC-A bar code begins and ends. The recommended minimum size for the quiet zones, in dimensions of the modules that we have used throughout, is 9 modules for both the left and right quiet zones.

The dimensions shown below are for a nominal size of UPC-A bar code. This is referred to as the 100% magnification. The nominal module or x-width size is 0.33 millimetres. Instances of the UPC-A bar code may be used down to 80% and up to 200% of the nominal size.

UPC bar code dimensions