Barcodes (UPC, EAN & Code 128): The Complete Guide
A barcode is a machine-readable identifier: a row of bars and spaces whose widths encode a short number or text that a scanner can read in a fraction of a second. This guide covers how that encoding works, which of the common formats — UPC, EAN-13, Code 128, ITF-14 and more — fits retail, inventory or shipping, what a check digit actually catches, where real product numbers come from, and how to size and print a barcode that scans the first time.
How a barcode actually works
Every 1D barcode is built from the same parts. The narrowest bar or space is one module (its printed width is called the X-dimension), and each character is a fixed pattern of bars and spaces measured in modules. A start pattern and stop pattern tell the scanner where the data begins and ends — and which way round it's being read, so a barcode scans upside down just as well. Around it sits the quiet zone: a blank margin the scanner needs to find the start pattern at all. Most retail and logistics formats end with a check digit or check character, calculated from the rest of the data, so the scanner can reject a misread instead of passing along a wrong number.
A scanner doesn't see the number printed underneath — that human-readable text is only there for people. It measures the relative widths of dark and light areas along a line, which is why contrast, bar color and a clean quiet zone matter far more than how the barcode looks on screen.
Choosing the right barcode format
The right format depends almost entirely on who will scan it. Anything going through a retail checkout needs a GS1 format (EAN or UPC); anything you label and scan yourselves can use whatever fits the data best — usually Code 128.
| Format | What it encodes | Typical use | Check |
|---|---|---|---|
| EAN-13 | 13 digits | Retail products worldwide, books (ISBN) | Mod 10 |
| UPC-A | 12 digits | Retail products in the US and Canada | Mod 10 |
| EAN-8 / UPC-E | 8 digits | Small packages with little label space | Mod 10 |
| ITF-14 | 14 digits | Outer shipping cartons (GTIN-14) | Mod 10 |
| Code 128 | All 128 ASCII characters, variable length | Inventory, assets, shipping labels, tickets | Mod 103 (built in, not printed) |
| Code 39 | A–Z, 0–9, space and - . $ / + % | Automotive, defense, older industrial systems | Optional Mod 43 |
| Code 93 | Same characters as Code 39, denser | Logistics where Code 39 is too wide | Two mandatory (C and K) |
| ITF | Even number of digits | Warehousing, cartons | Optional |
| Codabar | Digits and - $ : / . + with A–D start/stop | Libraries, blood banks | None required |
| MSI Plessey | Digits | Retail shelf labels, warehouse bins | Mod 10 (common) |
| Pharmacode | A number from 3 to 131070 | Pharmaceutical packaging control | None |
If you're unsure, the practical rule is: EAN-13 or UPC-A for anything sold in a store, Code 128 for everything else. Code 128 encodes the full ASCII character set — letters, numbers and symbols — with runs of digits packed at double density, and every modern scanner reads it. You can generate any of these formats with Frost Rank's free Barcode Generator.
UPC vs EAN: the same system, one digit apart
UPC-A and EAN-13 aren't competing standards — they're the same GS1 numbering system. A 12-digit UPC-A is simply an EAN-13 whose first digit is 0, left unprinted. Scan UPC-A 036000291452 with a scanner that reports everything in EAN-13 form and it returns 0036000291452: same product, same check digit. Since 2005, North American retailers have been required to accept EAN-13 as well, so a European EAN-13 scans at a US checkout without being re-labeled.
UPC-E is a compressed UPC-A for small packages: it suppresses runs of zeros to fit 12 digits into 8. The UPC-E 01234565, for example, expands to UPC-A 012345000065 — the scanner reconstructs the full number, so both identify the same product.
What a check digit catches — worked example
EAN-13, EAN-8, UPC-A and ITF-14 all use the same GS1 mod-10 check digit. Starting from the rightmost data digit, digits are multiplied alternately by 3 and 1, summed, and the check digit is whatever brings the total up to the next multiple of 10. For the UPC-A data 03600029145:
Digits: 0 3 6 0 0 0 2 9 1 4 5
Weight: 3 1 3 1 3 1 3 1 3 1 3
Weight-3 digits: (0 + 6 + 0 + 2 + 1 + 5) × 3 = 42
Weight-1 digits: 3 + 0 + 0 + 9 + 4 = 16
Total: 42 + 16 = 58
Check digit: (10 − (58 mod 10)) mod 10 = 2
Full UPC-A: 036000291452
That one digit catches every single-digit error — a smudged or mistyped digit always changes the total. It also catches almost every swap of two neighboring digits; the only swaps it misses are between digits exactly 5 apart, like 1↔6 or 3↔8, because the 3-vs-1 weighting changes the total by a multiple of 10 in that one case. That's why a wrong check digit is worth fixing before printing rather than after: a scanner will either reject the label outright or, worse, a manually keyed number will look valid for a different product.
Where real product numbers come from
Generating a barcode image is free; the number inside a retail barcode is not something to invent. EAN and UPC numbers are GTINs (Global Trade Item Numbers), allocated from a company prefix licensed by GS1 — the nonprofit that runs retail product identification in over 100 countries. Retailers and major marketplaces check that prefix against GS1's registry, and numbers resold by third-party sites frequently fail that check because the prefix belongs to a different company.
A few prefix ranges are reserved for specific uses and worth recognizing:
| EAN-13 prefix | Meaning |
|---|---|
| 978, 979 | ISBN — books |
| 977 | ISSN — magazines and periodicals |
| 200–299 | Restricted, in-store use (e.g. variable-weight deli and produce items) |
| 000–019, 030–039, 060–139 | GS1 US — numbers starting with 0 can also be printed as a 12-digit UPC-A |
For anything that never leaves your own systems — stockroom bins, equipment asset tags, library items, event tickets — you don't need GS1 at all. Use Code 128 with whatever identifier your inventory system already uses.
Printing barcodes that scan the first time
Size. A standard EAN-13 at 100% magnification is 37.29 × 25.93 mm with a 0.33 mm module, and GS1 allows roughly 80%–200% of that for general retail. Don't shorten the bar height to squeeze a label — a truncated barcode has to be scanned almost perfectly straight.
Quiet zone. Leave the blank margins intact: an EAN-13 needs at least 11 modules of space on the left and 7 on the right, and Code 128 needs at least 10 modules on each side. A label design that crops the white edges is one of the most common reasons a correct barcode won't scan.
Color. Most scanners read with red light, so red, orange and yellow bars look the same as white paper and simply disappear. Print dark bars — black, dark blue, dark green or dark brown — on a light background, and never invert it (light bars on dark).
Resolution. Every bar should land on a whole number of printer dots, or the printer's rounding makes some bars thicker than others. A 0.33 mm module is 3.9 dots on a 300 dpi label printer, so it prints as 4 dots — 102.6% magnification, which is fine. That's why vector SVG is the best format for print artwork: the printer rasterizes it at its own resolution. For a PNG, download it at a high resolution and place it at 100% scale — never stretch it unevenly.
Printing one barcode, a page of copies, or a sheet of labels
For a single label, the Print button on the Barcode Generator prints the barcode at exactly the size it shows (for example 105 × 34 mm) instead of stretching it to fit the page — so what comes out of the printer is what you designed. Choose "Fill a page" and it repeats the same barcode as many times as fit on one A4 or US Letter sheet, with light cut guides: handy for a box of identical stock items or a shelf of the same SKU.
When every label is different — stock labels, shelf tags or asset tags — paste one value per line into the Batch tab of the Barcode Generator: every line becomes its own barcode in the chosen format, check digits are calculated per line, and any invalid line is skipped and listed rather than blocking the whole sheet. Choose 2, 3 or 4 labels per row, then print — or choose "Save as PDF" in the print dialog to keep a file. Whatever you do, print at "Actual size" (100%), not "Fit to page", so the modules keep their intended width.
Test before you print thousands
Before committing to a print run, print one test label on the real material and scan it with the scanner that will actually be used, plus a phone scanning app as a second check. Confirm the scanned number matches exactly what you intended — not just that it scans — and check it at arm's length and at an angle. On a tightly curved surface like a bottle or can, turn the barcode sideways — "ladder" orientation, bars running horizontally — so its length follows the straight axis instead of wrapping around the curve.
Frequently asked questions
The check-digit example, the UPC-A/EAN-13 and UPC-E equivalences, and the error-detection claims in this guide were verified in code — including generating barcodes with Frost Rank's own Barcode Generator and decoding them with two independent scanner libraries (ZXing and zbar) — not taken on trust.
Was this tool helpful?
Rate it and leave a comment — takes 10 seconds, and genuinely helps decide what to fix or build next.