Skip to main content

How to Use a Barcode Generator: Code 128, EAN-13, UPC-A and Code 39 Explained

A practical guide to picking the right 1D symbology, computing EAN/UPC check digits, and printing barcodes that actually scan — with a real store-shelf example.

Published By 李雷
#barcode #ean-13 #retail #printing #guide

How to Use a Barcode Generator: Code 128, EAN-13, UPC-A and Code 39 Explained

A barcode looks like one of those problems that should be trivial — type a number, get a striped image. Then you print 400 of them, walk the warehouse floor with a handheld scanner, and a third of them refuse to read. The image was fine on screen. The encoding was correct. The print was wrong.

I've made every one of those mistakes, so this guide is the version I wish I'd had: which symbology to choose, how the check digit actually works, and the handful of print rules that decide whether your code scans on the first beep. You can follow along in the free Barcode Generator, which runs entirely in your browser and never uploads your data.

The four symbologies, and when each one fits

A "barcode" is not one format. The four 1D symbologies that cover almost everything real-world are these:

  • Code 128 — the workhorse. It encodes any printable ASCII (letters, digits, dashes, symbols), it's variable length, and it's dense. This is what you reach for on shipping labels, asset tags, and internal part numbers like BIN-A12-0033. If the code is for your own systems and not a store shelf, Code 128 is almost always the right answer.
  • EAN-13 — the 13-digit retail standard used on products worldwide. Digits only. If you're putting a product on a shelf outside North America, you need this with a number issued by GS1.
  • UPC-A — the 12-digit North American retail code. Same retail role as EAN-13, narrower geography. US retailers will ask for this on unit cartons.
  • Code 39 — alphanumeric like Code 128 but lower density and self-checking, with no required checksum. It's common in defence, automotive, and older warehouse systems, and it's rugged and forgiving. Good for event passes and asset tags where density doesn't matter.

The quick decision: internal use → Code 128. Retail shelf → EAN-13 (or UPC-A in the US). Legacy industrial system that asks for it by name → Code 39.

The check digit: what it is and why you don't type it

EAN-13 and UPC-A end in a mod-10 check digit, a single digit that lets a scanner catch a misread instead of charging the wrong price. The math is fixed and worth understanding even though the tool does it for you.

For EAN-13, take the 12 data digits and weight them alternately by 1 and 3 from the right, sum the products, and the check digit is whatever brings that sum up to the next multiple of 10. This odd/even weighting and mod-10 formula is defined in the GS1 General Specifications — it's not a vendor convention, it's the standard every retail scanner enforces. UPC-A uses the same idea with the weighting flipped.

You never have to compute it by hand. Type the 12 data digits for EAN-13 (or 11 for UPC-A) and the tool appends the correct check digit and shows you the full code. If you instead paste a complete 13- or 12-digit code, the tool recomputes the last digit and corrects it if it was wrong — which is a nice way to surface a typo in your source data, because a single fat-fingered digit in the middle changes the check digit at the end.

A real example: a barcode for a store listing

Here's the exact flow I ran for a product that needed to go on a shelf.

Input: I had the 12-digit number from my GS1 prefix — 4006381333393 — and selected the EAN-13 symbology.

What the tool did: it appended the check digit and produced the full 13-digit code, displayed under the bars in the standard 1-6-6 grouping. The trailing digit it computed was 1, so the full code read 4006381333931. (You can verify this yourself: the alternating 1/3 weighting of the first 12 digits sums to a value 1 short of a multiple of 10, so the check digit is 1.)

Output: a true vector SVG I copied straight into the print-ready artwork at 100% of the nominal 37.29 mm width, plus a 3x PNG for the packaging mock so the designer could drop it into the comp. The data and symbology live in the URL, so the share link reproduced the exact barcode for my packaging vendor — though for an unreleased GTIN I'd copy the file rather than the URL, since the link records the number in the destination's access log.

That's the whole job: pick the symbology, paste the data digits, let the tool handle the check digit and the human-readable line, export at the right size.

Printing rules that decide whether it scans

This is where most barcodes die, and it has nothing to do with the encoding. Three rules:

Don't print it too small. Scanners read the relative width of bars, and the narrowest bar — the "module" — has to survive the printer. If the module falls under about 0.33 mm in print, cheap handheld scanners start missing it. Export at 3x, target 300 DPI, and at a module width of 2 px you get roughly 6 device pixels per module, which prints clean. Then print one and scan it with the actual scanner from the distance it'll really be read at, before you commit to a run.

Don't clip the quiet zone. The blank margin on each side of the code is part of the symbol, not decoration. Designers crop it to tighten a layout and the barcode stops working. Keep at least 10 modules of clear space left and right. The single most common rejection at retail is a clipped left or right margin, not a bad number.

Don't reverse the contrast. Scanners need high contrast between the dark bars and a light quiet zone. Black bars on white is the safe default. Dark bars on a colored or dark background look fine on a monitor and fail on the scanner, so resist the urge to color-match the bars to your packaging.

Beyond 1D: when you actually want a QR code

1D barcodes hold an identifier — a number that points at a database row. If you need to encode a URL, contact card, or a chunk of text directly in the symbol, that's a 2D job: reach for a QR Code Generator instead, and use a QR Code Decoder to confirm what you encoded reads back correctly. And if the "data" you're putting on labels is a batch of unique IDs you still need to mint, a UUID Generator pairs naturally with Code 128 for asset tagging.

The dividing line is simple: a 1D barcode is a pointer, a QR code is a payload. Pick by what the scanner needs to do with it, generate it, and — always — scan-test one real print before the batch.


Made by Toolora · Updated 2026-06-13