Which barcode type should I use?
Code 128 is the most flexible linear barcode. It can hold letters, digits and punctuation, so it suits asset tags, inventory labels, shipping references, tickets and internal product codes. EAN-13 is the 13-digit barcode printed on retail products across most of the world, and EAN-8 is its shorter version for small packages. The 12-digit UPC-A codes used in North America can be written as EAN-13 by adding a leading zero.
How the barcodes are encoded
The generator implements the encoding rules from the barcode specifications directly in a few kilobytes of JavaScript. For Code 128 it starts in code set B, which covers all printable ASCII characters, and switches to the compact numeric code set C for runs of four or more digits, where each pair of digits takes a single symbol. That keeps barcodes for long numbers noticeably shorter. A modulo-103 check character is calculated and added automatically, followed by the stop pattern. For EAN codes, the first digit selects the pattern of odd and even parity used in the left half, the bars are split by centre guards, and the final digit is a check digit worked out with alternating weights of 1 and 3. Enter 12 digits for EAN-13 (or 7 for EAN-8) and the check digit is added; enter all 13 (or 8) and it is verified.
PNG or SVG?
The PNG download is a pixel image at the bar width you choose, good for documents and web pages. The SVG download is a vector image that stays perfectly sharp at any size, which is the better choice for printing labels, packaging and anything that will be scaled. Both include a white quiet zone on each side, the blank margin scanners need to find the start and end of the code.
Printing tips
- Print black bars on a white background; coloured or low-contrast combinations scan poorly.
- Do not stretch the barcode unevenly, and keep the quiet zones clear.
- Test a printed sample with a scanner or a phone barcode app before printing a large batch.
Important: retail product numbers
Anyone can draw an EAN-13 barcode, but selling products through retailers normally requires numbers that are officially licensed to your company by GS1. Made-up numbers may clash with real products. For internal use, Code 128 is the safer choice. For links and longer text, use the QR code generator instead.