Barcode Generator

EAN, UPC, Code 128, Code 39 and ITF-14, with the check digit worked out for you

What to encode

The barcode

How it looks

Six symbologies, drawn as SVG so they stay sharp at any size, and a PNG at four times the size for anything going to a printer. Nothing is uploaded, and the check digit is worked out here, not taken on trust.

The check digit

5 9 0 1 2 3 4 1 2 3 4 5  ?

weight every other digit by three, counting
from the right hand end:

1 3 1 3 1 3 1 3 1 3 1 3

5 + 27 + 0 + 3 + 2 + 9 + 4 + 3 + 2 + 9 + 4 + 15 = 83

83 to the next ten is 7. The check digit is 7.

Every retail barcode ends in a digit that is not data. It is a sum of the others, weighted alternately by one and three, chosen so the total lands on a multiple of ten. A scanner that reads a barcode and does not get a round number knows it misread something and tries again without telling you.

Type twelve digits and the thirteenth is added. Type thirteen and it is checked, and if it is wrong it is corrected and you are told. That last part matters: a barcode with a bad check digit still prints, still looks right, and is rejected months later at somebody else's loading bay.

The first digit is invisible

An EAN-13 has thirteen digits and room for twelve.

The first digit is not drawn at all. It is carried
by which of two patterns each of the next six
digits uses:

  5 -> O E E O O E

Change the first digit and the bars change shape
without getting any wider. That is why a scanner
can read one upside down.

An EAN-13 has room for twelve digits of bars, which is a problem given the name. The trick is that each of the first six digits can be drawn two ways, with an odd or an even number of bars, and the pattern of odds and evens spells out the thirteenth digit.

It has a useful side effect. The left half of the symbol always has odd or even parity in a specific arrangement and the right half never does, so a scanner reading the barcode upside down can tell immediately and flip it.

A UPC-A is the same symbol with the first digit fixed at zero, which is why scanning one with a phone gives you thirteen digits starting with a nought.

The white space is part of it

The white space either side is part of the
barcode.

Ten modules at each end for EAN, ten for Code 128,
and ITF-14 wants a bearer bar as well.

Print one flush against the edge of a label and
it will not scan, and nothing about it will look
wrong.

The most common reason a barcode does not scan is not the bars. It is that somebody put a border, a fold or the edge of the label too close to it. The scanner needs clear space to find where the symbol starts, and the standards are specific about how much.

The quiet zone here is included in what you download, so the SVG already has the right margin built into it. Do not crop it off.

Size

EAN-13 at the nominal size

  95 modules + 2 quiet zones of 9
  = 113 modules across
  = 37.29mm at 100%

Shrink it below about 80% and supermarket
scanners start refusing. Above 200% and it stops
fitting on the packaging.

Retail barcodes have a nominal size and a permitted range around it. Too small and the bars blur together under the scanner's beam; too large and the beam cannot sweep the whole symbol in one pass. The measurement under the controls tells you what you would get at 300 dots per inch.

Print black on white if you possibly can. Scanners read contrast in red light, so red bars are nearly invisible to some of them, and any light colour on any other light colour will not work at all. Dark blue or black on white or yellow is safe.

Which one to use

EAN-13 for anything sold in a shop outside North America, andUPC-A for anything sold in one inside it. Both need a company prefix that you buy from GS1, and a number you make up yourself will collide with somebody else's product sooner or later.

Code 128 for anything internal. It holds any printable ASCII, it is dense, and it packs digits two to a symbol when there are enough of them in a row to be worth switching for. It is the right default for asset tags, shipping labels and warehouse work.

Code 39 holds less and takes more space, but it needs no check digit and older equipment reads it happily. ITF-14 goes on the outer case instead of the item, and only holds digits, in pairs.

What has and has not been checked

The encoding tables here are verified structurally: the EAN patterns are checked against the relationships that define them, every Code 128 pattern is checked to add up to eleven modules, and every Code 39 character to have exactly three wide elements. Every possible EAN-13 shape is also encoded and read back by a separate decoder that recovers the digits from the bars, including the first one from its parity.

What has not happened is a real scanner reading one off a real printer. If these are going on something that matters, print one and scan it before you print ten thousand. That is worth doing with any barcode from any source.