How does a store scanner know which product it is reading? The answer is a 13-digit EAN-13 barcode printed on the package. The EAN-13 Barcode Generator builds that image from 12 digits. It also calculates the final check digit.
The tool helps small sellers, makers, and warehouse staff create barcode images for labels and tests. The barcode is drawn in your browser from the digits you type. This guide explains each result and shows where the tool falls short.
Table of Contents
- What the Generator Does
- How to Use It, Step by Step
- The EAN-13 Check Digit Formula
- Worked Example
- How to Read the Results
- GS1 Prefixes and Registration
- Limitations and Assumptions
- FAQs About the EAN-13 Barcode Generator
What the Generator Does
The tool takes 12 product digits and returns a complete 13-digit EAN-13 code. You can also type all 13 digits to have the last one checked. It then draws the matching barcode image. The page shows three result cards, one preview, and two buttons.
- EAN-13 Code: the full 13-digit number, or N/A when no code can be made.
- Checksum Digit: the calculated 13th digit by itself.
- Length Validation: a status line, such as "Valid: check digit added" or "Too short (4 digits)".
- EAN-13 Barcode Preview: the barcode image, with the digits printed under the bars.
- Random Code: fills the input with 12 random digits from the browser's secure random generator, then redraws the barcode.
- Download EAN-13 Image: saves the preview as a PNG file. It stays disabled until a barcode is drawn.
How to Use It, Step by Step
- Type or paste 12 digits into the "12 or 13 Digit EAN Code" field.
- Spaces and hyphens are fine. The tool ignores them, so you can paste a formatted number.
- Read the EAN-13 Code card. It shows your 12 digits followed by the calculated check digit.
- To check an existing code, type all 13 digits instead. The tool compares the last digit with the calculated one.
- Read the Length Validation card. It states whether the input is complete and correct.
- Look at the EAN-13 Barcode Preview. It updates after every keystroke, and the Enter key recalculates too.
- Click "Download EAN-13 Image" to save the barcode as a PNG file.
The EAN-13 Check Digit Formula
The check digit helps catch reading and typing errors. The tool multiplies each of the first 12 digits by a weight of 1 or 3. The weights alternate from left to right.
Weighted Sum→Sum mod 10→10 minus Remainder→Check Digit
Positions 1, 3, 5, 7, 9, and 11 get weight 1. Positions 2, 4, 6, 8, 10, and 12 get weight 3. The variables work like this.
- d1 to d12: the 12 data digits, read from left to right.
- Sum: d1 plus 3 times d2, plus d3, plus 3 times d4, continuing through d12.
- Check Digit: 0 when Sum mod 10 is 0. Otherwise, it equals 10 minus that remainder.
Worked Example
Start with the sample value 590123412345. Multiply each digit by its weight, then add the products.
| Position | Digit | Weight | Product |
| 1 | 5 | 1 | 5 |
| 2 | 9 | 3 | 27 |
| 3 | 0 | 1 | 0 |
| 4 | 1 | 3 | 3 |
| 5 | 2 | 1 | 2 |
| 6 | 3 | 3 | 9 |
| 7 | 4 | 1 | 4 |
| 8 | 1 | 3 | 3 |
| 9 | 2 | 1 | 2 |
| 10 | 3 | 3 | 9 |
| 11 | 4 | 1 | 4 |
| 12 | 5 | 3 | 15 |
The products add up to 83. The remainder after dividing by 10 is 3. Ten minus 3 gives 7, so the check digit is 7. The full EAN-13 Code is 5901234123457, which matches the Checksum Digit card.
Another example uses 400638133393. Its weighted sum is 89, so the remainder is 9 and the check digit is 1. The tool outputs 4006381333931.
How to Read the Results
The Length Validation card names the status of your input. These are the messages the tool shows, and each one changes the other cards in a set way.
- Valid: check digit added: you typed 12 digits. The tool adds the check digit to the EAN-13 Code card and draws the barcode.
- Valid: check digit matches: you typed 13 digits, and the last one is correct. The tool keeps your number as the code.
- Invalid: check digit mismatch: the 13th digit is wrong. Typing 5901234123450 gives this message, because the last digit should be 7. The code card shows N/A, the Checksum Digit card shows 7, and no barcode is drawn.
- Too short or Too long: the number of digits is outside the 12 or 13 range. The message gives the count you entered, and no code is drawn.
- Invalid characters: the field holds a letter or symbol other than a space or hyphen. The message lists each one, such as "Remove: A, B, C."
- Enter 12 or 13 digits: the field is blank. The tool shows no code and draws no barcode.
GS1 Prefixes and Registration
The first two or three digits of an EAN-13 code form a GS1 prefix. GS1 member organizations assign these prefixes to businesses. A company usually gets its prefix from its national GS1 member organization.
The tool does not check whether a prefix is assigned to anyone. A random code may match a real product that another company owns. Use random codes only for tests, mockups, and training.
For a different barcode type, the Code 128 barcode generator covers letters and numbers. You can also compare the wider barcode generator options before you choose a format.
Limitations and Assumptions
- The tool does not check GS1 registration, code uniqueness, or print quality.
- It creates one barcode at a time and has no bulk mode.
- The 13th digit never changes the calculated code. The tool only compares it with the result.
Explore more utilities in the developer tools hub. Need a two-dimensional code instead? Try the QR code generator.
FAQs About the EAN-13 Barcode Generator
Is an EAN-13 Barcode the Same as a UPC Code?
They are closely related. A UPC-A code becomes an EAN-13 code when you add a leading zero. Type that zero plus the 11 digits before the UPC check digit. The tool then calculates the same final digit that the UPC carries.
Why Does the Barcode Image Not Appear?
The preview uses the JsBarcode script, which loads from cdnjs.cloudflare.com. If that script is blocked or fails to load, the page still shows the calculated code. A message explains that the image could not be drawn. Check your connection, then reload the page.
What Is the Download File Name?
The file is named ean13 followed by the 13-digit code, such as ean13-5901234123457.png. Different codes produce different file names, so you can keep several downloads in one folder.
Can I Change the Barcode Size or Format?
No. The tool exports only PNG files with a fixed white background and margin. It has no size, bar width, or SVG options. To make the image larger, resize it in an image editor. Check that the bars stay sharp enough to scan.
Will a Printed Barcode Scan Correctly?
Print one test label before you use the barcode on products. Check that the printed digits match the EAN-13 Code card. Then scan the label with the scanner you plan to use. Print size and contrast affect scanning, so test at your real label size.
This calculator gives general estimates only and is not professional advice. Reviewed for general accuracy by Prof. Dr. Khalil Mudassar, PhD.