How each barcode is drawn
EAN-13 is 95 narrow units (modules) wide: a start guard, six digits on the left, a centre guard, six on the right and an end guard. Each digit takes 7 modules as two bars and two spaces. The very first digit isn’t drawn as bars at all: it is hidden in the pattern of odd and even codes used for the left six digits. UPC-A is the same as an EAN-13 that starts with 0. Code 128 draws each character as 11 modules in three bars and three spaces; it has three character sets, and we switch to set C, which packs two digits into one character, whenever that makes the barcode shorter. Code 39 uses nine elements per character, three of them wide, with * at each end.
Worked example
EAN-13 check digit for 590123412345: weighting the digits 1, 3, 1, 3… from the left gives 5×1 + 9×3 + 0×1 + 1×3 + 2×1 + 3×3 + 4×1 + 1×3 + 2×1 + 3×3 + 4×1 + 5×3 = 83. The next multiple of 10 is 90, so the check digit is 7 and the full number is 5901234123457. For Code 128 text PJJ123C in set A, the start value 103 plus each character’s value times its position (48×1 + 42×2 + 42×3 + 17×4 + 18×5 + 19×6 + 35×7) is 878, and the remainder after dividing by 103 is the check symbol, 54. In Code 39 the optional mod 43 check for CODE39 is W.
GS1 numbers for retail
The bars are free to make; the number inside an EAN or UPC is not. GS1, the global standards body, gives each company a company prefix and companies build product numbers (GTINs) from it. Shops, supermarkets and online marketplaces use the number to look up who made the product, so numbers bought from resellers or made up can be refused and listings removed. If you sell through retailers, join GS1 in your country (GS1 US, GS1 UK and so on) or buy individual GTINs from GS1, then enter those numbers here. For internal labels, Code 128 needs no registration.
Printing tips
- Print black bars on white; red bars are invisible to most laser scanners.
- Keep the quiet zones (white margins) at least 10 modules wide; we include them in the files.
- Test-scan a printed sample with a phone or scanner before printing thousands.
Related tools
- QR code generator
- Wi-Fi QR code generator
- Invoice generator
- eBay fee calculator
- Profit margin calculator
- Break-even calculator
Sources
- GS1 General Specifications (EAN/UPC symbols and check digits)
- GS1: How to calculate a check digit manually
- GS1 US: Get started with UPC barcodes (company prefix)
Frequently asked questions
Which barcode type should I use?
Can I use these barcodes on products I sell?
How is the EAN-13 check digit worked out?
What size should I print a barcode?
SVG or PNG?
Last updated: 2026-11-26