Barcode Generator
A barcode generator for UPC-A, EAN-13, EAN-8, Code 128 and Code 39, drawn as SVG in your browser, with the check digit worked out or verified.
Barcode
- Symbology
- EAN-13
- Encoded data The leading 4 is not drawn as bars of its own. It sets which left-hand digits use L and which use G: here LGLLGG.
- 4 006381 | 333931
- Check digit Weights of 3 and 1 alternate, with 3 on the rightmost data digit: 4x1 + 0x3 + 0x1 + 6x3 + 3x1 + 8x3 + 1x1 + 3x3 + 3x1 + 3x3 + 9x1 + 3x3 = 89. The check digit is what brings that to a multiple of ten: 90 - 89 = 1.
- 1, matches the digit entered
- Prefix The first digits of an ordinary GS1 number say which national GS1 office issued the company prefix, not where the product was made or who owns the brand.
- GS1 prefix 400
- Modules The symbol is 95 modules wide with 30 bars, and the standard requires 11 blank modules on the left and 7 on the right. The left margin is the wider one because that is where the leading digit is printed.
- 95 + 11 + 7 quiet = 113
- Printed width 31.35 mm (1.234 in) of bars, at an X-dimension of 0.33 mm (13 mils). GS1 sets a nominal X-dimension of 0.330 mm for retail barcodes and allows 80% to 200% of it, 0.264 to 0.660 mm, for scanning at a checkout. This size is inside that range. Scale the whole barcode, height included, rather than squeezing it in one direction, and never trim the quiet zones to make it fit.
- 37.29 mm (1.468 in) with quiet zones
- On a label printer And 3.9 dots at 300 dpi, so 4 (0.339 mm).
- 2.6 dots at 203 dpi, so 3 (0.375 mm)
| Digit | Weight | Product | Drawn as |
|---|---|---|---|
| 4 | 1 | 4 | parity LGLLGG |
| 0 | 3 | 0 | L 0001101 |
| 0 | 1 | 0 | G 0100111 |
| 6 | 3 | 18 | L 0101111 |
| 3 | 1 | 3 | L 0111101 |
| 8 | 3 | 24 | G 0001001 |
| 1 | 1 | 1 | G 0110011 |
| 3 | 3 | 9 | R 1000010 |
| 3 | 1 | 3 | R 1000010 |
| 3 | 3 | 9 | R 1000010 |
| 9 | 1 | 9 | R 1110100 |
| 3 | 3 | 9 | R 1000010 |
| 1 (check) | - | 89 + 1 = 90 | R 1100110 |
How the Barcode Generator works
A barcode is a row of modules (the narrowest bar or space the symbol uses), and every bar and space is a whole number of them wide. What differs between symbologies is how characters become widths, what checks the result, and how much blank space has to surround it.
EAN-13 and UPC-A are the retail barcodes. A UPC-A is twelve digits; an EAN-13 is thirteen, and a UPC-A is an EAN-13 whose first digit is 0, drawn with identical bars. A UPC barcode generator draws the twelve-digit UPC-A; EAN-13 is the thirteen-digit form. Both are 95 modules: a start guard (bar, space, bar), six digits of seven modules each, a center guard, six more digits and an end guard. Each digit is two bars and two spaces. Left-hand digits use the L patterns, which have an odd number of dark modules, and right-hand digits the R patterns, which are L inverted and so have an even number. That is how a scanner tells which half it is reading and in which direction. A third set, G, is R reversed. EAN-13's extra digit is not drawn at all: the leading digit selects which of the six left-hand digits use L and which use G, and the scanner works it out from that mix. EAN-8 uses the same patterns with four digits a side.
The check digit is the last digit, and it is arithmetic, not data. Take the other digits, weight them 3 and 1 alternately starting with 3 on the rightmost, and add. For the EAN-13 400638133393, that is 4x1 + 0x3 + 0x1 + 6x3 + 3x1 + 8x3 + 1x1 + 3x3 + 3x1 + 3x3 + 9x1 + 3x3 = 89. The check digit is whatever brings the total to a multiple of ten, so 1, and the full number is 4006381333931. The rule catches every single wrong digit and most swaps of neighboring digits.
Code 128 encodes any ASCII text. It has three character sets (A for capitals, digits and control codes; B for capitals, lowercase and punctuation; C for pairs of digits) and symbols for switching between them mid-barcode. Set C packs two digits into one 11-module symbol, so a long run of digits is roughly half the width in C. Choosing where to switch is the one decision an encoder makes; this one searches for the shortest sequence outright. The check symbol is the start value plus each following symbol's value times its position, mod 103, and it covers the switch symbols too.
Code 39 encodes capitals, digits, space and - . $ / + %. Each character is five bars and four spaces, three of them wide, with a narrow gap between characters and an asterisk at each end. It is wider than Code 128 for the same text but very forgiving of poor printing. Its mod 43 check character is optional.
Size. The X-dimension is the module width. GS1's nominal for retail is 0.330 mm, which makes an EAN-13 37.29 mm wide including its quiet zones, and the allowed range is 80% to 200% of that. The quiet zones are part of the symbol: 11 and 7 modules for EAN-13, 9 for UPC-A, 7 for EAN-8, 10 for Code 128 and Code 39. On a thermal label printer, round the module to a whole number of dots: at a fraction, some bars print a dot wider than others and the width ratios the scanner decodes drift.
Prefixes. Retail EAN and UPC numbers are issued by GS1 (in the US, GS1 US) through a licensed company prefix. A few ranges are reserved: 978 and 979 are books, 977 is periodicals, and numbers beginning with 2 are for in-store use such as weighed produce, which is why they never work outside the store that printed them.
Barcode Generator FAQ
Can I use this barcode to sell on Amazon or in a store?
The image will scan, but whether the number is accepted depends on where it came from. Retailers and marketplaces generally expect EAN and UPC numbers licensed from GS1 under your own company prefix, and they check the prefix against the brand. A barcode generator, this one included, draws whatever number you give it; it cannot make that number yours.
What is the difference between UPC-A and EAN-13?
Twelve digits versus thirteen, and nothing else in the bars. A UPC-A is an EAN-13 with a leading zero, so 036000291452 as a UPC-A and 0036000291452 as an EAN-13 are the same barcode. Scanners everywhere read both. UPC-A is the convention in the US and Canada and EAN-13 elsewhere.
Why does it say my check digit is wrong?
Because the last digit does not match the mod 10 calculation over the others. The usual cause is a mistyped digit elsewhere in the number, not a wrong check digit, since catching mistyped digits is what the check digit is for. Recomputing the check digit gives a valid-looking number, but it is only right if the other digits are.
Which barcode type should I use?
For a retail product, the EAN-13 or UPC-A your GS1 number was issued as. For anything internal (shipping labels, inventory, asset tags), Code 128, which encodes any ASCII text and is the most compact for digits. Code 39 only if a system or customer requires it.
Why are the numbers not part of the image?
The digits printed under a retail barcode are for people, not scanners. They are given as text under the image, to add in a plain typeface in your label layout if the label needs a human-readable line.