Barcode Generator
Generate Code128, EAN-13, and UPC-A barcodes as SVG or PNG
Digits, letters, and symbols allowed (printable ASCII). Common for logistics and inventory.
12–13 digits. Enter 12 and the 13th check digit is calculated; enter 13 and the check digit is verified. Global retail barcode standard.
11–12 digits. Enter 11 and the 12th check digit is calculated; enter 12 and the check digit is verified. North American retail barcode standard.
Your barcode updates instantly as you type.
Working…
0.0
It hasn't frozen — the result will appear when the calculation finishes.
About Barcode Generator
This generator produces three linear barcodes: EAN-13, the 13-digit code printed on retail packaging worldwide; UPC-A, the 12-digit code used in North America; and Code 128, which carries letters, digits and punctuation for things like shipping labels, bin locations and asset tags. The first two are tied to a numbering system that identifies a trade item. Code 128 is a free-form container.
That difference decides which one you want. If the product has to beep at a supermarket checkout, you need a number issued through GS1 encoded as EAN-13 or UPC-A. If the label is for your own warehouse or inventory, Code 128 is the natural choice.
Working out an EAN-13 check digit
The last digit of an EAN-13 is computed from the first twelve. Multiply digits in odd positions (counting from the left) by 1 and digits in even positions by 3, add everything up, and the check digit is whatever brings the sum up to the next multiple of 10. The scanner repeats that calculation on every read and discards any read where it fails, which catches nearly every single-digit misread and most swaps of adjacent digits.
Enter twelve digits and the tool appends the check digit. Enter thirteen and, if the last digit does not match, the tool does not generate a barcode; it shows the digit you entered next to the computed one. Take that seriously: when a number copied from a package fails the check, the more likely explanation is a typo somewhere else, and swapping in the computed digit would give you a barcode for a different number.
What the first three digits do and do not mean
The leading two or three digits are the GS1 prefix, which identifies the GS1 member organization that issued the number. 001–019, 030–039 and 060–139 are GS1 US ranges (the ones that line up with UPC-A), 880 is GS1 Korea, 450–459 and 490–499 are GS1 Japan, and 840–849 is GS1 Spain. Some prefixes are not countries at all: 978 and 979 are Bookland (ISBNs), 977 is for ISSNs, and 200–299 are reserved for restricted in-store use, such as variable-weight items at a deli counter.
Despite the popular belief, the prefix is not a country of origin. A Korean company manufacturing in Vietnam still uses its 880 number, and GS1 itself states that prefixes do not indicate where a product was made. Checking the first digits to see whether a product is imported does not work.
Any thirteen digits with a valid check digit will produce a scannable symbol here. For retail use, though, the number has to come from a GS1 Company Prefix licensed to you; a made-up number may collide with someone else's product, and large retailers verify registrations.
UPC-A is EAN-13 with a hidden leading zero
A 12-digit UPC-A becomes a valid EAN-13 by adding a 0 in front, and the bar pattern is identical. That is why every EAN-13 scanner reads UPC-A. The check digit is calculated on that zero-padded 13-digit form, and this tool does exactly that: give it eleven digits and it completes the twelfth.
Code 128: long runs of digits get cheaper
Each Code 128 symbol is 11 modules wide, and the symbology has three code sets. This tool switches automatically between set B, which covers printable ASCII (codes 32 to 126), and set C, which packs two digits into one symbol. Whenever four or more digits appear in a row it switches to C, so a long numeric ID comes out roughly half as wide as a text string of the same length.
Every Code 128 barcode ends with a modulo-103 check symbol: the start symbol's value plus each symbol's value multiplied by its position, divided by 103, keeping the remainder. It is not printed in the human-readable line, but the scanner uses it to reject misreads. Set A, which carries control characters, is not implemented, so tabs, line breaks and non-ASCII text such as accented letters cannot be encoded. Input is limited to 80 characters.
Worked examples
Check digit by hand
- Input
First 12 digits: 880123456789- Output
8801234567893
Weights alternate 1, 3: 8 + 24 + 0 + 3 + 2 + 9 + 4 + 15 + 6 + 21 + 8 + 27 = 127. The next multiple of 10 is 130, so the check digit is 3.
Code set switching
- Input
ABC-1234567- Output
13 symbols plus the stop pattern, 145 modules, check value 67
ABC- goes in set B, 123456 becomes three set C symbols, and the leftover 7 returns to set B. Check: 104 + 33×1 + 34×2 + 35×3 + 13×4 + 99×5 + 12×6 + 34×7 + 56×8 + 100×9 + 23×10 = 2745, and 2745 mod 103 = 67.
Digits versus letters
- Input
12345678 and ABC-123, both Code 128- Output
79 modules and 112 modules
Eight digits fit in four set C symbols, so the barcode is narrower than one for seven letters and symbols. For small labels, all-numeric IDs are the compact option.
UPC-A completion
- Input
03600029145- Output
036000291452
The check digit 2 is computed on the padded form 003600029145, the same way a scanner would.
How to use it
- Choose the format: EAN-13 or UPC-A for product numbers, Code 128 for anything else.
- Type the value. Twelve digits for EAN-13 or eleven for UPC-A is enough; the check digit is added.
- Adjust bar height and margins, but keep the side margins, since scanners need them to find the start.
- Download PNG or SVG and test with a real scanner or phone app before printing labels.
Frequently asked questions
Can I put these barcodes on products I sell?
The bars are generated to the specification, but for retail the number must be one assigned to you through GS1. Invented numbers can clash with existing products, and major retailers and marketplaces check that a code is registered.
Why does an accented letter cause an error?
Code 128 as implemented here only encodes printable ASCII. For text with accents or non-Latin scripts, a QR code, which stores UTF-8, is the right tool.
Can I use colored bars?
Most laser and imaging scanners read with red light and look for a reflectance difference. Red bars on white can vanish under red light. Keep dark bars on a light background.
Why is there no barcode after I entered thirteen digits?
The last digit does not match the check digit computed from the first twelve. Rather than silently changing it, the tool shows both values. If you copied the number from existing packaging, recheck the other digits first; if they are right, delete the last digit and it will be computed.
Sources
- GS1 — GS1 Company Prefix
- GS1 — Check digit calculator (method)
- Wikipedia — List of GS1 country codes
- Wikipedia — Code 128
Last reviewed: