A barcode is a number or a short text written as bars that a scanner can read in a split second. This generator makes the three formats most people need: EAN-13 and UPC-A for products, and Code 128 for everything else, from shipping labels to inventory tags. Everything happens in your browser and there is nothing to install.
How to use it
- Pick the type: EAN-13, UPC-A or Code 128.
- Type the code. For EAN-13 you can type 12 digits and let the page add the check digit, or all 13 to have it checked. For UPC-A it’s 11 or 12 digits. Spaces and dashes are ignored.
- Choose the bar width (1 to 4 pixels per module) and whether to show the digits under the bars.
- Download the result as SVG or PNG.
If something is wrong, such as a letter in an EAN-13, the wrong number of digits or a check digit that doesn’t match, the page tells you instead of drawing a barcode that won’t scan.
The check digit, step by step
EAN-13 and UPC-A end in a check digit that lets the scanner catch a misread. The rule, set by GS1, is the same for both. Take the example 400638133393:
- Starting from the right, multiply the digits by 3, 1, 3, 1 and so on: 3, 9, 3, 3, 3, 1, 8, 3, 6, 0, 0, 4.
- The digits multiplied by 3 are 3, 3, 3, 8, 6 and 0, which add up to 23, times 3 is 69.
- The others are 9, 3, 1, 3, 0 and 4, which add up to 20.
- 69 + 20 = 89. The next multiple of 10 is 90, so the check digit is 1.
The full code is 4006381333931. For the UPC-A 03600029145 the same steps give 58, so the check digit is 2 and the code is 036000291452. A Montana Department of Agriculture guide for producers selling to stores describes the same structure: a company prefix, an item number and a final check digit.
How the bars are built
Each EAN-13 and UPC-A digit takes seven modules, drawn as two bars and two spaces. The left half uses one set of patterns and the right half another, so a scanner knows which way the code is facing. In an EAN-13, the first digit isn’t drawn as bars at all; it’s encoded in which of two pattern sets the next six digits use. Taller guard bars mark the start, the middle and the end.
Code 128 works differently. Each symbol is 11 modules wide, made of three bars and three spaces of one to four modules. It has three character sets; this generator uses set B for text and set C, which packs two digits into one symbol, for runs of digits. ABC123456 is encoded as A, B, C, a switch to set C, then 12, 34 and 56. That’s 8 symbols with the start code instead of 10. A checksum (the weighted sum of the symbols, modulo 103) and a stop pattern close the code.
Getting real product numbers
The bars only carry a number. For retail, that number must be unique worldwide, so stores require GTINs issued by GS1 US or the GS1 office in your country. Marketplaces such as Amazon check product codes against the GS1 database.
| Use | Format | Where the number comes from |
|---|---|---|
| Products in US stores | UPC-A | GS1 US |
| Products in other countries | EAN-13 | Your country’s GS1 office |
| Books | EAN-13 starting with 978 or 979 | Your country’s ISBN agency |
| Warehouse, shipping, assets | Code 128 | Your own system |
Printing tips
- Keep the white margin on both sides. The page leaves the standard quiet zone: 11 modules on the left of an EAN-13, 9 on each side of a UPC-A and 10 on each side of a Code 128.
- Print dark bars on a light background. Red bars, or bars on a red or dark background, often fail.
- Don’t squeeze the barcode to fit. Resize it evenly, and prefer the SVG for print.
- Scan a test print with a phone before printing hundreds of labels.