HandyTools Hub

Barcode Generator

Create professional barcodes in multiple formats

The Barcode Generator turns a short string of text or digits into a scannable black-and-white barcode image, rendered live on an HTML canvas and downloadable as a PNG. It supports four common retail and logistics formats, needs no account or upload, and validates every code against the rules of the format you select.

How to Use the Barcode Generator

  1. Pick a format: Code 128, EAN-13, EAN-8, or UPC-A. The hint under the input explains what that format accepts.
  2. Type or paste the data. Validation runs on every change, and the download button stays disabled until the value is valid.
  3. Set the width (200–800 px) and height (50–300 px) with the sliders, and choose whether to print the human-readable text below the bars.
  4. Check the live preview. The renderer reserves a quiet zone of about 10% of the width on each side so scanners can find the start and stop patterns.
  5. Click Download to save the result as a PNG named barcode.png.

Validation is strict about the character set but not about business rules: a value can pass every check and still be an unregistered number, as described below.

Choosing the Right Format

FormatInput acceptedCheck digitTypical use
Code 128Printable ASCII 32–126, any lengthModulo 103, automaticInternal IDs, shipping labels, asset tags
EAN-1312 or 13 digitsModulo 10, auto-addedRetail products worldwide
EAN-87 or 8 digitsModulo 10, auto-addedSmall packages where space is tight
UPC-A11 or 12 digitsModulo 10, auto-addedRetail in the US and Canada

Code 128 is the only option that carries letters and punctuation; the three retail formats are digits only. For a product sold only in the US or Canada, UPC-A is the local convention. For anything sold internationally, choose EAN-13. EAN-8 compresses the same idea into a shorter symbol, which also means a shorter number space and less room for product variation.

The retail numbers have a fixed structure. A UPC-A code is one number-system digit, a five-digit manufacturer code, a five-digit product code, and the check digit. An EAN-13 code is a GS1 prefix, a company prefix, an item reference, and the check digit. The tool can calculate the final digit, but it cannot allocate the manufacturer or company portion — that comes from GS1.

How Each Symbology Encodes Data

Code 128 uses Code Set B, where every character maps to a symbol whose value is its ASCII code minus 32, so a space is 0 and ~ is 94. The encoder writes a start symbol, one symbol per character, a checksum symbol, and a stop symbol as alternating bars and spaces whose widths run from 1 to 4 modules. The checksum is (104 + Σ position × value) mod 103. For ABC the values are 33, 34 and 35, so the weighted sum is 104 + 1×33 + 2×34 + 3×35 = 310; 310 mod 103 = 1, so the checksum symbol carries value 1.

The retail formats use a modulo-10 check digit, where digits are weighted 3 and 1 alternately from the right. For the 12-digit body 590123412345, the weighted sum is 83, so the check digit is 10 − 3 = 7 and the complete code is 5901234123457. The tool adds that digit for you whenever you type the short form, and the bars always encode the checked, complete value.

Worked Examples

  • Enter 590123412345 as EAN-13. The preview encodes 5901234123457 and prints that number under the bars.
  • Enter INV-2024-0001 as Code 128 for an internal label that mixes letters, digits and hyphens.
  • Enter 03600029145 as UPC-A. The twelfth digit is computed and appended automatically.
  • Enter 1234567 as EAN-8. The eighth digit is added, producing a compact code for a small package.

Common Mistakes

  • Typing a full 13-digit EAN with a wrong check digit. The tool accepts 13 digits, but the encoder builds the bars from the first 12 and never verifies the last one. If the printed number and the bars disagree, a scanner trusts the bars.
  • Using accented letters or typographic punctuation in Code 128. Only ASCII 32–126 is accepted, so Café is rejected while Cafe passes.
  • Printing too small. A barcode squeezed into a few millimetres loses the narrow-bar contrast scanners depend on. Keep the quiet zone visible on both sides and avoid going below roughly 2 cm of printed width for retail codes.
  • Assuming a valid-looking code is a registered one. A number can pass the check-digit test and still belong to no company, in which case no retail system will recognise the product.
  • Switching format without re-entering the data. A string that is valid Code 128 is usually invalid EAN-13, so the input is re-validated and the old value is cleared from the canvas.

What the Tool Does Not Do

It does not issue GS1 prefixes, so for retail EAN/UPC codes you still need a company prefix assigned by GS1. There is no support for Code 39, ITF-14, PDF417, Data Matrix or QR, no GS1-128 application identifiers or FNC1 escape codes, no batch or CSV generation, and no SVG output — the download is a PNG. Colours are fixed black on white for maximum contrast, and the rendered image is a bitmap, so enlarging a small PNG later will soften the bar edges.

Frequently Asked Questions

Does the generator add the EAN-13 check digit for me?

Yes. If you type the 12-digit body of an EAN-13 code, the tool calculates the modulo-10 check digit and appends it, then encodes the complete 13-digit value. The same applies to EAN-8 (7 digits in) and UPC-A (11 digits in). If you paste all 13 digits yourself, the tool uses them as given.

Why does Code 128 reject an em dash or an accented letter?

The encoder implements Code Set B, which covers printable ASCII from 32 (space) to 126 (tilde) only. Characters such as é, ü, ’, or — fall outside that range and are rejected. Transliterate them to plain ASCII (for example, Cafe instead of Café) before generating.

Can I encode a GS1-128 application identifier such as (01) or (10)?

No. Although both are called Code 128, GS1-128 adds FNC1 escape characters and an Application Identifier syntax that this tool does not implement. It produces plain Code 128 Code Set B only, which is fine for internal asset and inventory labels but not for GS1 supply-chain data.

If I type all 13 digits of an EAN-13, does it verify my check digit?

No. When you supply 13 digits, the encoder always builds the bars from the first 12 and does not confirm that the thirteenth is correct. A scanner reads the bars, so a mistyped check digit can make the printed number disagree with the machine-readable code. Prefer typing only the 12-digit body.

How small can I print the barcode before scanners struggle?

It depends on the scanner, but as a rule keep a retail EAN/UPC code at least 2 cm wide and taller than about 1 cm, and leave the blank quiet zone visible on both sides. Raising the width slider spreads the same number of modules over more pixels, which increases the narrow-bar contrast at print time.

Which format should I choose for a product sold only in the United States?

UPC-A. It is the 12-digit standard used by most US and Canadian retailers, while EAN-13 is the international 13-digit standard. Choose EAN-13 for packaging that will be sold outside North America, and EAN-8 only when the label surface is too small for a full-size code.

Reviewed by the HandyTools Hub team · Last updated