Data Tools

Line Barcode Guide: Picking and Making the Right 1D Barcode

By Smart Tools Utility Team · Published October 7, 2026 · Updated October 7, 2026 · 8 min read

A linear (1D) barcode is a row of bars and gaps that encodes a short string, read by sweeping a laser or camera across it. It is the format behind supermarket checkouts, parcel labels and library books. The hard part is rarely drawing the bars. It is choosing the symbology (the encoding scheme) that fits your data, and knowing the rules each one imposes: length, allowed characters and check digits. This guide covers the twelve types in our Line Barcode Generator, with results from actually generating codes with it and decoding them with ZXing and OpenCV, two independent open-source readers.

Which barcode type should you use?

Start from what the barcode is for.

If you need to store a URL, a long text or more than a few dozen characters, a 1D code is the wrong tool. Use a QR code or a 2D barcode instead.

How to generate a barcode, step by step

  1. Pick a Barcode Type. A line of grey help text under the input box changes to describe that type's rules.
  2. Enter your value in Barcode Text / Data. The preview redraws as you type, and the Generate button redraws on demand. Clear empties the box and shows the prompt "Enter text above to generate barcode".
  3. Set Bar Width (Narrow 1x, Normal 2x, Wide 3x, Extra Wide 4x) and Height (60, 100, 150 or 200 px).
  4. Tick or untick Show text below barcode, and choose the bar and background colours with the two colour pickers.
  5. Download with Download PNG, Download JPG, Download SVG or Download PDF. The files are called barcode.png, barcode.jpg, barcode.svg and barcode.pdf.
  6. Scan the file before you print hundreds of labels.
The Line Barcode Generator showing a Code 128 barcode for INV-2026-00417 with the human-readable text underneath
A Code 128 barcode for the value INV-2026-00417, with the bar width at Normal (2x) and the height at Normal (100px).

What each type accepts, tested

We fed the tool valid and invalid values for every type and decoded each result. The table below summarises what we saw. "Decoded" means ZXing returned the value shown.

Type        Input                       Result
Code 128    Hello, World! #42           decoded as typed
Code 128    é                           error (non-ASCII)
Code 39     abc-123                     drawn as ABC-123
Code 39     A_B                         error
ITF-14      1234567890123 (13 digits)   check digit added: 12345678901231
ITF-14      12345678901234              error (wrong check digit)
EAN-13      590123412345 (12 digits)    check digit added: 5901234123457
EAN-13      5901234123458               error (wrong check digit)
EAN-8       9638507 (7 digits)          check digit added: 96385074
UPC-A       03600029145 (11 digits)     check digit added: 036000291452
Codabar     123456                      A added at both ends: A123456A
ISBN        9780306406157               decoded as EAN-13
ISBN        978-0-306-40615-7           error (hyphens)
GS1-128     0100614141007349            decoded as (01)00614141007349
SSCC        1234 5678 9012 3456 75      decoded as (00)123456789012345675
SSCC        12345                       error naming the digit count

Two details are worth remembering. First, the help text says EAN-13 needs "exactly 13 digits", but the tool also accepts the 12 digits without the check digit and calculates the last one for you. The same is true for the other numeric types: 7 digits for EAN-8, 11 for UPC-A, 13 for ITF-14. Second, if you type all the digits yourself and the check digit is wrong, the tool does not correct it; it simply fails.

Check digits, and why a "wrong" number is rejected

Retail barcodes end with a check digit, calculated from the others so that a misread is caught immediately. For EAN-13 the rule is: starting from the left, add the digits in odd positions, add three times the digits in even positions, and the check digit is what brings the total up to the next multiple of ten. For 590123412345 that is 17 + 3 × 22 = 83, so the check digit is 7, which is exactly what the generator appended to give 5901234123457. If you typed 5901234123458 yourself, the tool refuses it, which is the useful behaviour: a barcode with a bad check digit would be rejected by every till.

The generated EAN-13 and UPC-A images were also read back by OpenCV's barcode detector as 5901234123457 (EAN-13) and 036000291452 (UPC-A). ZXing reports a UPC-A as an EAN-13 with a leading zero, which is normal, since the two are the same symbology family.

Ready to make a barcode?

Open the Line Barcode Generator

When you see "Invalid data format"

Every failure except SSCC shows the same sentence: Invalid data format for the selected symbology rules. It does not say what is wrong, so check these in order:

  1. Is the type right? Letters in an EAN, UPC, ITF-14 or MSI barcode are rejected. Switch to Code 128 if you need mixed text.
  2. Is the length right? Compare your digit count with the help text under the input box. Remember the 12-instead-of-13 shortcut.
  3. Is the check digit wrong? Delete it and let the tool calculate it.
  4. Does the text have hyphens, spaces or non-ASCII characters? ISBN with hyphens fails, and so does a Code 128 value containing an accented letter.
  5. Is it a number in range? Pharmacode accepts 3 to 131070. We confirmed 2 and 131071 are rejected.
The Line Barcode Generator with EAN-13 selected, a value with an invalid check digit, and the error message Invalid data format for the selected symbology rules
An EAN-13 value with a wrong check digit gives a general error message and an empty preview.

Watch out: after an error, the preview empties, but the download buttons stay active, and they save the last barcode that did draw. In our test, clicking Download PNG after the error above saved the earlier INV-2026-00417 image. Check the preview before every download.

Size, colour and scanning

The output is a PNG drawn on a canvas, and its pixel width comes from the bar width. For the 14-character value INV-2026-00417 in Code 128, the image was 198 pixels wide at 1x, 376 at 2x, 554 at 3x and 732 at 4x. The image is taller than the Height setting: 42 pixels more when text is shown (a 100 px setting gave 142 px) and 20 pixels more without it. All sixteen width and height combinations decoded in ZXing.

GS1-128 and SSCC for logistics

GS1-128 is Code 128 with a special start marker that tells the scanner the content is a series of numbered fields (application identifiers). In the tool, enter the digits with no brackets, such as 0100614141007349: the 01 is the identifier for a trade item number (GTIN) followed by the 14 digits. Scanners display it as (01)00614141007349. Entering the brackets yourself also produced a code that decoded as (01)00614141007349, but the bars are not the same as the no-brackets version, so follow the help text and leave them out.

SSCC, the 18-digit Serial Shipping Container Code, is simpler: enter the 18 digits (spaces and dashes are removed) and the tool adds the 00 identifier for you. We entered 1234 5678 9012 3456 75 and ZXing read (00)123456789012345675. A wrong count gives the specific message "SSCC must be exactly 18 digits (you entered 5)". The tool does not validate the SSCC check digit: 123456789012345670, whose check digit is wrong (it should be 5), was accepted without complaint, so verify it yourself.

Limits and a few known issues

Quick answers

Can I put a URL in a line barcode? Code 128 can hold it, but the code becomes very wide and fragile. Use a QR code.

Why does my EAN-13 start with a different number from what I typed? It does not; it only gains a check digit at the end when you typed 12 digits.

Is a generated EAN valid for selling in shops? It is a well-formed barcode, but the number must be issued to you by GS1, otherwise it may clash with another company's product.

Ready to make a barcode?

Open the Line Barcode Generator