Barcode Generator: Code 128, EAN-13, UPC-A and the Check Digit That Protects You From Errors

You have a small warehouse and want each box to carry a code a worker scans to learn what is inside. Or you want a label for a product you sell. Or you need a code to track parcels. A barcode is the answer, but there are many types, each with rules. Sahel's barcode generator produces four common types and calculates the check digit itself, so you avoid the errors that make a scanner reject a code.
How a barcode works
A barcode is black and white bars of different widths. The scanner shines light on them and measures what bounces back, turning the sequence of widths into digits or characters. The bars themselves carry no product information, only a number or text. The real details, such as name and price, live in a database the system looks up by that number. So a product barcode is really an "identification number", and all its details are in the shop's system.
The four types
- Code 128: encodes letters, digits and common symbols, and is best for stock, parcels and internal labels. It holds text of a reasonable length and is dense, so it takes little space.
- EAN-13: thirteen digits, the worldwide standard for retail products outside North America.
- EAN-8: a short eight-digit version for small products that cannot fit a full code.
- UPC-A: twelve digits, the standard in North America. UPC-A can be thought of as a special case of EAN-13 with a leading zero.
The simple rule: if the code is for your own internal use, choose Code 128 because it is the most flexible. If it is for a product to be sold in shops, choose EAN-13 or UPC-A according to the market.
The check digit: the silent guard
The last digit of an EAN or UPC is not data but a "check digit" calculated from the digits before it. Its use is that the scanner recomputes it on reading, and if the last digit does not match, there was a reading or printing error, so it rejects the code instead of recording a wrong number. It is meant to catch common mistakes such as a mistyped digit or two swapped digits.
The EAN-13 method: multiply the first twelve digits alternately by 1 and 3 starting from the left, add the results, and the check digit is whatever brings the total up to the next multiple of ten. For example, for 590123412345 the sum is 5 + 27 + 0 + 3 + 2 + 9 + 4 + 3 + 2 + 9 + 4 + 15 = 83, the next multiple of ten is 90, so the check digit is 7 and the full code is 5901234123457. Doing this by hand is easy to get wrong, which is why the tool does it for you.
That is why the tool asks for eleven digits for UPC-A, twelve for EAN-13 and seven for EAN-8, and calculates the last one itself. If you enter the full number with a wrong check digit, the tool warns you and shows the correct one.
A barcode that looks fine but has a wrong check digit will not be read by a shop scanner. Never type the last digit by hand.
Official product numbers
The tool draws the symbol, but it does not give you the right to use a particular number. EAN and UPC numbers begin with a company prefix issued by GS1 in your country, so that the same number is not given to two different products anywhere in the world. If you will sell through large retailers or major online marketplaces, obtain your numbers officially. For internal use in your own stockroom, use Code 128 with any text you like; no registration is needed.
Barcode or QR code?
A linear barcode carries a number or short text and is read very quickly by cheap shop scanners, which makes it best for products and stock. A QR code holds links and longer text and is read by a phone camera, which makes it best for marketing and information. If you need one, try Sahel's QR code generator.
Tips for a barcode that scans first time
- Contrast: black bars on a white background, and no pale colours for the bars.
- Quiet zones: leave white space on both sides of the symbol, since the scanner needs it to know where it starts.
- Size: do not shrink it too far. Very small symbols make thin bars blur together when printed.
- Do not stretch it: changing the width-to-height ratio distorts the bar widths.
- Test before a large print run: print one copy and scan it with your phone or scanner.
How to use it
- Choose the type: Code 128, EAN-13, EAN-8 or UPC-A.
- Enter the value. For the numeric types, enter the digits without the check digit.
- Check the preview and any note about the digit count or check digit.
- Download the symbol as SVG for sharp printing or PNG for quick use.
A realistic scenario
The owner of a small workshop has two hundred kinds of parts and wants shelf labels. He chooses Code 128 and types each part code such as SH-0042, downloads the symbols as SVG and prints them on labels. He plugs a cheap scanner into his computer, and scanning a label is enough to bring up the item in his spreadsheet. He did not need to register any number, and did not buy any software.
Frequently asked questions
Which barcode types are supported?
Code 128 for text and numbers, and EAN-13, EAN-8 and UPC-A for retail products.
What is a check digit?
A last digit calculated from the digits before it to catch entry and printing errors. The tool calculates it for you.
Will any scanner read it?
Yes. The symbols follow the standards and are read by shop and phone scanners when printed with suitable contrast and size.
Do I need to register a product to sell it?
Official EAN and UPC numbers must come from GS1. For internal use, Code 128 is enough.
Is what I type sent to a server?
No. The symbol is drawn in your browser.
Related articles

Percentage Calculator: How to Work Out Discounts, Increases and Percent Change Without Mistakes

Sort Lines, Remove Duplicates and Clean Text Lists: Quick Tools for Long Text

GPA Calculator: How Grade Point Average Is Worked Out and What You Need to Reach Your Target
