Barcode Generator for Code 128, EAN-13, UPC-A
Code 128, EAN-13 and UPC-A barcodes with check digits, as SVG or PNG
Any ASCII text. Shipping labels, asset tags, inventory and internal IDs.
Which barcode type do you need?
Use Code 128 for anything internal: shipping and warehouse labels, asset tags, library cards, order numbers, serials. It encodes any ASCII text (letters, digits, punctuation and even control characters such as tab), it is compact, and every common handheld and phone scanner reads it.
Use EAN-13 or UPC-A only for products sold through retail. These are GS1 numbers: the first digits are a company prefix that a business licenses from its national GS1 organisation, and the shop's point-of-sale system looks the number up in its product database. Generating the barcode image is free and this page does it, but making up a number does not give you a valid product code, and marketplaces such as Amazon check registered prefixes. UPC-A is the 12-digit form used in the US and Canada; EAN-13 is the 13-digit form used everywhere else and also for books, where the ISBN-13 is the EAN-13 (prefix 978 or 979). A UPC-A number is the same as an EAN-13 with a leading zero, and modern scanners read both.
How the check digit is calculated
EAN-13 and UPC-A end with a check digit so a scanner can catch a misread. Starting from the digit immediately left of the check digit and moving left, multiply the digits alternately by 3 and 1, add the products, and take the amount needed to reach the next multiple of 10. For 400638133393, the weighted sum is 89, so the check digit is 1 and the full EAN-13 is 4006381333931.
Type 12 digits for EAN-13 (or 11 for UPC-A) and this generator appends the check digit. Type the full 13 (or 12) and it verifies the last digit, refusing to draw a barcode with the wrong one and telling you the correct number instead. That catches the most common copy-paste and typing mistakes before anything is printed.
Code 128 has its own check symbol, a weighted sum of every symbol value modulo 103, which is added automatically and is not shown in the text under the bars.
Code 128 code sets and automatic switching
Code 128 has three code sets. Set B covers printable ASCII including lowercase letters, set A covers uppercase letters, digits and control characters, and set C packs two digits into each symbol, so long numbers take half the width. This encoder picks the set for you: it starts in C when the text begins with four or more digits, switches into C for any run of four or more digits in the middle, uses A only when a control character needs it, and uses B for everything else. An odd-length run of digits sends its first digit in the current set before switching, so no digit is wasted.
The encodings were checked against the JsBarcode library's output and decoded back to the original text for strings mixing letters, digit runs and control characters. GS1-128 (FNC1 application identifiers) is not supported; if your carrier requires GS1-128 labels, use their labelling software.
Printing barcodes that scan
Download SVG for print. It is a vector file made of rectangles, so the bars stay exactly the width the symbology defines at any size, which is what scanners need; resizing a low-resolution PNG is the usual cause of fuzzy, unreadable bars. Use PNG (rendered at twice the on-screen size) for documents, spreadsheets and web pages.
Keep the quiet zones, the blank margins at each end. The generated image includes them: 11 modules on the left and 7 on the right of an EAN-13, 9 on each side of a UPC-A and 10 for Code 128. Black bars on a white background are the safest choice. Red bars are invisible to the red lasers most scanners use, and low contrast or a dark background will fail. EAN-13 and UPC-A are designed for a nominal width of about 37 mm; you can print smaller, but test with the scanner that will actually be used.
How to use the Barcode Generator for Code 128, EAN-13, UPC-A tool
- 1
Choose the barcode type
Pick Code 128 for internal labels and IDs, or EAN-13 / UPC-A for retail product numbers you have from GS1.
- 2
Enter the text or number
For EAN-13 and UPC-A, type the number without the check digit to have it added, or with it to have it verified.
- 3
Adjust size and text
Set the bar width and height, choose colours with strong contrast, and toggle the human-readable text under the bars.
- 4
Download SVG or PNG
Download a vector SVG for print or a 2x PNG for documents, then test-scan it before printing in bulk.
Frequently asked questions
Is this barcode generator free for commercial use?
Yes. The barcode images are generated in your browser and you can use them anywhere. What is not free is a registered retail number: EAN and UPC numbers for products sold in shops come from GS1, and the barcode is only as valid as the number in it.
Can I make up an EAN or UPC number?
You can generate a barcode for any number with a correct check digit, which is fine for testing or internal use. For products sold in retail or on Amazon, you need a GS1 company prefix, otherwise the number may belong to someone else or be rejected.
Why does it say my check digit is wrong?
The last digit of an EAN-13 or UPC-A is computed from the others with the mod-10 rule. If it does not match, one of the digits was probably mistyped. The message shows the correct check digit; double-check the number against its source before using it.
Does Code 128 support lowercase letters and spaces?
Yes. Code 128 encodes all 128 ASCII characters, including lowercase, spaces, punctuation and control characters. It does not encode accented letters or other non-ASCII characters; use a QR code for those.
Related Image Tools
Image to Base64
Convert images to Base64-encoded data URIs
Base64 to Image
Convert Base64 strings back to downloadable images
Image Resizer with Locked Aspect Ratio
Resize images client-side with custom dimensions
Image Cropper
Crop images with a visual selection tool
Image Format Converter
Convert images between PNG, WebP, and JPEG formats
Image Color Palette Extractor
Extract dominant colors from any image
Get the next tool before you need it
One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.

