Skip to main content
Back to BlogUtility Guides

How to Generate a Barcode (and Pick the Right Format)

Generate a scannable barcode by picking the right format, computing the check digit, and keeping the quiet zone. Covers EAN-13, UPC-A, Code 128, ITF-14, Codabar, and Pharmacode.

The Toolbox TeamAugust 13, 20267 min read

The problem: eleven formats, one right answer

You need a barcode on a product, a shipping carton, or a shelf label, and you're staring at a dropdown with eleven formats. Pick the wrong one and the scanner at the receiving dock rejects it — or worse, it scans but encodes the wrong number, so the box lands in the wrong bin and nobody notices for a week. The format is the decision you have to get right; drawing the bars is the easy part.

Fastest path

Open the Barcode Generator, pick the format, type the value, download PNG or SVG. For a retail product going into international stores: choose EAN-13, type 12 digits, and the tool appends the check digit for you.

Input:  590123412345
Output: 5901234123457   ← 13th digit computed, not invented

That's the whole interaction. The rest of this guide is about the part the dropdown can't decide for you.

The parts a generator can't decide for you

1. The format is the real decision

The symbology is determined by where the barcode lives, not by what looks good. Get this wrong and the downstream system won't read it.

You're labeling a… Use Why
Retail product (international) EAN-13 13 digits, the global standard outside North America
Retail product (US/Canada) UPC-A 12 digits, North American retail
Small retail item (no label room) EAN-8 8 digits, for tiny packages
Shipping carton / GS1 GTIN-14 ITF-14 14 digits, printed on corrugated outer cartons
Warehouse shelf, inventory part Code 128 or Code 39 Alphanumeric, fits your own part numbers
Library book, blood bank Codabar Starts and ends with A–D as sentinels
Pharmaceutical packaging Pharmacode A number from 3 to 131071

If you're unsure: EAN-13 for products sold outside North America, UPC-A inside it. A UPC-A is just an EAN-13 with a leading 0 — the tool encodes UPC-A that way internally — so Amazon and GS1-registered brands treat them as the same namespace.

2. The check digit is computed, not invented

This is the one that bites people. EAN-13, EAN-8, and UPC-A all end in a check digit derived from the other digits by a mod-10 algorithm. You do not make it up. If you type a 12-digit EAN-13, the 13th digit is forced; type 13 with one digit wrong and the code is invalid, and a checkout scanner rejects it with a beep that costs you a customer's patience.

The algorithm: weight the digits 1, 3, 1, 3… from the left, sum them, take the next multiple of 10. For 590123412345:

5·1 + 9·3 + 0·1 + 1·3 + 2·1 + 3·3 + 4·1 + 1·3 + 2·1 + 3·3 + 4·1 + 5·3
= 5 + 27 + 0 + 3 + 2 + 9 + 4 + 3 + 2 + 9 + 4 + 15
= 83   →   next multiple of 10 is 90   →   check digit = 7

Full code: 5901234123457. The tool both computes the 13th from 12 and validates a full 13-digit entry, telling you the correct check digit when yours is wrong. EAN-8 uses the same algorithm but the weighting starts with 3, not 1, because there are 7 data digits and the 3-weight runs right-to-left. Don't try to reuse an EAN-13 check digit for an EAN-8 — they're not the same.

3. The quiet zone

Every 1D barcode needs blank space to its left and right — the quiet zone — or a scanner can't find where the code starts. The GS1 minimum is 10× the width of the narrowest bar. The tool's margin control defaults to 20px, which is usually fine at a 2px bar width. If you crank the bar width up or drag the margin down to make the label prettier, expect scan failures at retail checkout. Margin 0 is a self-inflicted wound.

4. Color and contrast

Laser scanners read dark bars on a light background. That is the whole rule. Black on white is the safe default. Red bars on white look fine to your eye, but a red laser passes straight through red — so red reads as background and the code effectively disappears. The tool's color presets include light-on-dark options that work for QR codes (phone cameras read contrast, not color) but will fail most 1D laser scanners. Use the fancy palettes for QR. Stick to black-on-white for anything that has to scan at a till.

5. Print sizing

For a label that scans first time, the narrow bar — the "X dimension" — has to match what your printer can hold. The tool's presets get you close: label (~72 DPI), shelf tag (~150 DPI), retail standard (~200 DPI). For GS1-compliant retail the EAN-13 X dimension is 0.330 mm nominal; smaller than that and checkout scanners start struggling. If you're printing at home on an inkjet, the retail preset is the floor, not the ceiling — go bigger.

Gotchas

  • Codabar needs start and stop letters. The value must begin and end with A, B, C, or D — A12345B, not 12345. Drop the sentinels and the code is invalid. Libraries and blood banks use those letters as delimiters.
  • Pharmacode is a number, not a string. The legal range is 3 to 131071. Outside that, nothing encodes, and the tool will tell you so.
  • Code 39 is uppercase. Lowercase input is accepted and silently uppercased, so part-abc-001 becomes PART-ABC-001 on the barcode. If your downstream system is case-sensitive, that mismatch will haunt you.
  • UPC-E is not a free shortening of UPC-A. It only applies to UPC-A codes that start with a 0 and have enough zeros in the right positions. You can't compress an arbitrary UPC-A into UPC-E.
  • QR error correction is a tradeoff, not a freebie. L (7% recovery) gives the densest code; H (30%) lets you overlay a logo or survive damage but inflates the size. For a URL on a printed flyer, M (15%) is the sweet spot — readable even if the print smudges.

Summary

  • Match the format to the use case: EAN-13 for international retail, UPC-A for North America, Code 128 for shipping and inventory, ITF-14 for outer cartons, Codabar for libraries.
  • The check digit is computed, not invented — type one fewer digit and let the tool append it, or type the full code and let the tool verify it.
  • Keep a real quiet zone (leave the margin alone), and use black bars on white for anything a laser has to read.
  • Generate at the Barcode Generator; for 2D codes the QR Code Generator is the dedicated tool, and UUID Generator / Password Generator cover the other "give me a unique identifier" jobs.