Practical guide
How to generate an EAN-13 or Code 128 barcode
A label should decode to exactly the identifier your system expects. This guide explains format selection, check-digit arithmetic and testing the finished print. Producing an image is separate from assigning a product number: do not replace an authorized number with an example from this guide.
Choose the format your receiving system expects
EAN-13 mode renders a thirteen-digit number. If preparing a product label for sale, use a number you can correctly assign to that product. The generator neither assigns a GTIN nor checks its allocation. A matching check digit proves arithmetic consistency only, not your entitlement to use the number.
Choose Code 128 for your own identifier, such as MAG-001, when the warehouse system or recipient expects that format. This is ordinary Code 128, not GS1-128 with FNC1 and Application Identifiers. A visually similar symbol cannot replace a courier’s, retailer’s or customer’s requirements. Confirm the format before designing a label.
| Format | Enter | Important limitation |
|---|---|---|
| EAN-13 | 12 or 13 ASCII digits | Does not assign a GTIN |
| Code 128 | 1–80 printable ASCII characters | Not GS1-128 |
Source: GS1 — product numbering, quiet zones and print quality; JsBarcode — EAN-13 and Code 128 encoding documentation.
Enter EAN-13 without losing leading zeroes
Select EAN-13 and enter only the number, with no spaces between digits. Twelve digits form the body: the tool appends its calculated check digit. With thirteen digits, it checks the final digit and rejects an incorrect number instead of silently changing it. Leading and trailing field whitespace is ignored.
Leading zeroes belong to the identifier, so copy the number as text rather than a spreadsheet numeric value. Example 012345678901 produces 0123456789012, not a shorter number without its zero. Every value below is a technical example and may coincide with an allocated number; do not use these on products.
| Input | Result |
|---|---|
| 590123412345 | 5901234123457 |
| 5901234123457 | 5901234123457 |
| 5901234123454 | Error: expected check digit 7 |
| 012345678901 | 0123456789012 |
Calculate the check digit step by step
For body 590123412345, multiply digits from the left by alternating weights 1 and 3. The products are 5, 27, 0, 3, 2, 9, 4, 3, 2, 9, 4 and 15. Their sum is 83. Reaching the next multiple of ten, 90, requires 7, so the complete example ends in 7.
The general formula is (10 − (sum mod 10)) mod 10. The final mod 10 produces digit 0 when the sum is already divisible by ten. When checking thirteen digits, do not include the last digit in the body. If the result differs from your document, check the number’s source rather than changing it merely to generate an image.
| 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 |
Preserve the exact Code 128 identifier
Select Code 128 and enter a value such as MAG-001. Printable ASCII is supported, including digits, basic letters, spaces and common punctuation. The 80-character cap belongs to this tool. Polish accented letters, emoji, tabs and line breaks are unsupported; an entry consisting only of spaces is rejected.
Letter case and spaces are preserved, including at the beginning and end. MAG-001 differs from mag-001 or MAG-001 with an extra space. Do not append an EAN check digit to a Code 128 identifier; leave symbol construction to the encoder. After scanning, compare the complete decoded text with your system, not only the label beneath the bars.
Source: JsBarcode — EAN-13 and Code 128 encoding documentation.
Download the image and make a test print
After generation, download SVG or PNG. SVG preserves sharp edges when resized; PNG needs sufficient resolution at its final size. Do not stretch the image unevenly or crop the white areas beside the bars. Preserve dark bars on a light background; decorative artwork should stay out of the margins.
Do not treat the preview’s pixel dimensions as an approved label size. Printing requirements depend on the application and recipient. Make a sample using the intended printer and material, then read it with the intended scanner. A successful phone scan alone is neither quality certification nor proof of compliance with a retailer’s requirements.
Source: GS1 — product numbering, quiet zones and print quality.
Distinguish a data error from a scanning problem
An EAN-13 error usually requires comparing length and check digit with the source. A Code 128 error can indicate an unsupported character or excessive length. If a symbol was generated but will not scan, check the reader’s enabled format, margins, sharpness and print. Do not alter a product identifier to conceal a device problem.
Editing a field or resetting removes the previous result and download links but does not delete files already saved to your device. Generate the current code and replace it in the label artwork. Report problems using a demonstration identifier and browser/scanner details, without customer data. The generator does not query a product database or send label content to analytics.
Frequently asked questions
Does the generator assign a product GTIN?
No. It renders the supplied digits and checks the check digit. A number for sale must be properly obtained and assigned under the applicable rules. Neither a guide example nor a valid image confirms product registration.
Can I enter twelve EAN-13 digits?
Yes. The tool appends the thirteenth, check digit. With thirteen digits, it checks the last one and rejects an incorrect number without automatic repair. Leading zeroes remain part of the result; keep the identifier as text.
Is Code 128 the same as GS1-128?
Not in this tool. It provides ordinary Code 128 without FNC1 or GS1 Application Identifier support. If the recipient requires GS1-128, use a solution implementing those rules; simply adding parentheses to ordinary text is not sufficient.
Are entered data saved or sent to analytics?
Content and images are generated locally. Form data are not added to the URL, localStorage, sessionStorage or analytics. Downloads, copying and printing are deliberate actions. A page visit still makes a normal hosting request; protect exported files and your clipboard too.
Sources and scope
The generator creates an image and checks selected technical rules; it does not assign a GTIN, verify product registration or certify print quality. Demonstration numbers may coincide with real numbers and are not for selling products. Commercial use requires an appropriate number and compliance with the recipient’s and GS1 requirements.
Tools covered by this guide
QR code generator
Create static QR codes for links, text, Wi-Fi, phone numbers and contact cards. Download SVG or PNG.
Barcode generator
Create EAN-13 or Code 128 barcodes. Check the check digit and download a black-and-white SVG or PNG.