← Back

Barcode Generator

Supports CODE128/EAN-13 and other encodings

Different barcode formats have their own input rules — EAN-13 and UPC-A are international retail barcode standards requiring exactly 13 and 12 digits respectively, while CODE128 and CODE39 are more flexible and support letters and numbers. Everything is generated locally in your browser, with no network lookup required.

About Barcode Generator

This tool encodes text or numbers into a one-dimensional barcode, draws it on the page and lets you download it as a PNG. It supports four formats: CODE128, EAN-13, UPC-A and CODE39, and shows the human-readable text under the bars. It is important to be clear about scope. It only encodes and draws. It does not look anything up in a product database and it does not register product codes for you. Retail EAN-13 and UPC-A numbers have prefixes assigned by official numbering bodies, so a number you make up may scan perfectly well without being a legitimately registered product code.

How to use it

  1. Type what you want to encode into Barcode Content. When the page opens it contains 123456789012.
  2. Click the format you need under Encoding Format: CODE128 (general purpose, letters and numbers), EAN-13 (retail barcode, needs 13 digits), UPC-A (North American retail barcode, needs 12 digits) or CODE39 (common in industrial use).
  3. The barcode redraws automatically whenever you type or switch format, so there is no generate button. If the content does not suit the format, a red message appears below the inputs.
  4. When the barcode looks right, click Download Barcode Image. The file is named barcode- followed by the format name, for example barcode-CODE128.png.

How each format really behaves

The page uses the open-source JsBarcode library. We ran several inputs through that same library to see what happens. CODE128 accepts 123456789012 and abc-123 but cannot encode Chinese characters. CODE39 accepts abc-123 and ABC 12 with a space, and it converts lowercase letters to uppercase, so the text under the bars becomes ABC-123. EAN-13 has a special case. Entering the 12 digits 123456789012 makes the library append a check digit, giving 1234567890128. Entering the full 13 digits 1234567890128 also works, but 1234567890123, whose last digit is wrong, fails. UPC-A behaves the same way: the 11 digits 12345678901 gain a check digit and become 123456789012, the 12 digits 123456789012 pass, and 123456789013 with the wrong check digit fails. So "needs 13 digits" on the format button is only shorthand; 12 digits also work, and the thirteenth is calculated for you. The red error message states this rule too.

Limits and known quirks

  • Only CODE128, EAN-13, UPC-A and CODE39 are supported. There are no QR codes, Data Matrix, ITF, Codabar and so on.
  • Bar width, height and font size are fixed in the code (bar width 2, height 80). You cannot change the size or the colours on the page.
  • EAN-13 and UPC-A accept digits only. A wrong length or check digit makes generation fail and shows the message that generation failed and the input should match the selected format, spelling out the 12/13-digit rule (11/12 for UPC-A).
  • Clearing the input box also clears the barcode and any error message, and Download then produces no file.
  • Spaces at the start and end of the content are trimmed before encoding.
  • Whether a scanner can read the result depends on print quality, size and quiet zones. The tool cannot guarantee a printout will scan, so test with your real equipment before relying on it.

Which format should I choose?

For internal IDs, warehouse locations or asset tags, CODE128 is usually the most convenient: it encodes letters, digits and common symbols and is more compact than CODE39. CODE39 has a limited character set but is still used by many older systems. EAN-13 and UPC-A are for retail products and the numbers should come from the official numbering system. Do not use invented numbers to pose as real products.

Why does my 13-digit EAN fail?

The last digit of an EAN-13 is a check digit calculated from the first 12. If you enter all 13 digits and the last one does not match the calculation, the code is rejected. You can fix this by entering only the first 12 digits so the tool fills in the check digit, or by checking whether you have copied the number incorrectly.

Can I hide the text under the bars?

No. The readable text under the barcode is always shown and there is no option to hide it. CODE39 shows letters in capitals.

What kind of image do I get?

A PNG bitmap exported directly from the canvas on the page. Because it is a bitmap, enlarging it for print makes it blurry, so place it in your design software at its original size or an exact multiple and avoid stretching it.

Privacy and processing

The barcode is generated entirely in your browser. The page loads the JsBarcode library, which is bundled with the site, only when needed. It does not send what you type to a server and it does not look up product information online. The downloaded image is saved to your device by the browser. Nothing is stored between visits, and the input returns to its default value when you reload.