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 the 13 digits in an EAN-13 actually mean
An EAN-13 isn't just a random number — its structure identifies exactly where the product came from in the global supply chain. The first 2 or 3 digits are the GS1 country prefix (also called the member organization prefix), which shows where the company licensed its number, not where the product was manufactured: 00–13 is GS1 US, 30–37 is GS1 France, 400–440 is GS1 Germany, 50 is GS1 UK, 690–699 is GS1 China. That prefix is assigned by the local GS1 member organization, not by the company.
After the country prefix comes the company prefix (also called the manufacturer number), a unique block allocated by GS1 to that specific business. How many digits the company gets depends on how many products it plans to number: a small business might get a 9-digit prefix leaving 3 digits for item references, while a large manufacturer gets a shorter 6- or 7-digit prefix leaving more room for products. The company then assigns the remaining digits as item references — one unique number per product or variant — so no two of its products share the same barcode. Finally, the last digit is the check digit, calculated from all the digits before it.
A few prefix ranges have special meanings: 978 and 979 are ISBN book numbers converted into EAN-13 form, 977 is ISSN periodicals, and 200–299 are reserved for internal retail use like variable-weight items priced at the counter. The structure is what makes GTINs globally unique: GS1 assigns each member organization a non-overlapping prefix range, those organizations assign non-overlapping company prefixes within it, and each company assigns unique item references within its own prefix.
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.
How to get a barcode for your product
Getting a retail barcode is two separate jobs: licensing the number, then making the image. In short:
- Check whether you need a GS1 number at all. Selling through retailers or marketplaces, yes. For internal stock, asset tags or tickets, no: use Code 128 with your own IDs.
- License GTINs from GS1 in your country. Some GS1 offices, including GS1 US, sell single GTINs to small sellers; a company prefix pays off once you have many products. Every size, color and pack count needs its own number.
- Pick the symbol. UPC-A is the norm in the US and Canada and EAN-13 almost everywhere else, and both scan worldwide. Our comparison of UPC vs EAN for product sellers covers marketplace rules and small-package options.
- Generate the image and test-scan it before printing a full run, as described below.
For the full process, including why resold "cheap UPC" numbers get listings rejected, read our step-by-step article on how to get a barcode without buying one from a reseller.
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. A test label costs nothing: generate a free UPC, EAN or Code 128 barcode, print it at true size and scan it before ordering the full run.
Frequently asked questions
A traditional (1D) barcode stores data in the widths of bars along one line, so it holds a short identifier — typically a product number or SKU of up to a few dozen characters — and is read by laser or camera scanners at checkouts and in warehouses. A QR code is a 2D matrix that stores data both horizontally and vertically, holding up to several thousand characters and built-in error correction, which is why it's used for URLs, Wi-Fi logins and contact cards read by phone cameras. Use a barcode where a retail or warehouse scanner will read it; use a QR code when a person with a phone will.
Only for the number, and only if you sell through retailers. Generating the barcode image is free; what retailers require is a GTIN licensed from GS1, so your product number can't collide with another company's. Internal labels for stock, assets or events can use any number or Code 128 text with no GS1 membership at all. See where real product numbers come from.
Use UPC-A if you sell mainly in the US and Canada, and EAN-13 everywhere else; retail scanners worldwide read both. They are the same numbering system: a UPC-A is an EAN-13 whose first digit is 0. So an EAN-13 starting with 0 becomes a UPC-A by dropping that zero, with the same check digit, while an EAN-13 starting with any other digit has no UPC-A version. See how UPC and EAN relate.
The last digit of an EAN-13, UPC-A, EAN-8 or ITF-14 number, calculated from all the other digits with the GS1 mod-10 formula. When a scanner reads the barcode it redoes the sum; if the result doesn't match the last digit, it rejects the scan instead of ringing up the wrong product. That catches every single misread digit and most swaps of two neighboring digits. See the check digit worked out step by step.
Usually because something was added for you. EAN-13, EAN-8, UPC-A and ITF-14 end in a check digit calculated from the other digits; MSI Plessey appends a Mod 10 check digit; Codabar wraps the data in start/stop letters (A…A by default); and a 6-digit UPC-E gains a leading number-system digit and a trailing check digit. Frost Rank's Barcode Generator shows exactly what was added in the status line under the input, so the number that scans is never a surprise.
The first two or three digits are the GS1 prefix of the member organization that issued the number — 400–440 is GS1 Germany, 50 is GS1 UK, 590 is GS1 Poland — which reflects where the company registered, not where the product was made. Next comes the company's own prefix, then an item reference the company assigns to each product, and finally the check digit. A few prefix ranges are special: 978 and 979 are ISBNs (books), 977 is ISSNs (periodicals), and 200–299 are reserved for in-store use such as variable-weight items priced at the deli counter.
The Code 128 symbology itself sets no fixed maximum, but every extra character makes the barcode physically wider, and scanners, label sizes and reading distance set the practical limit — most real-world Code 128 labels hold roughly 10–30 characters. GS1-128, the variant used on standardized shipping labels, caps data at 48 characters and 165 mm of physical width. If you need to encode something much longer, like a full URL, a QR code is the better tool.
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 guide helpful?
Rate it and leave a comment — takes 10 seconds, and genuinely helps decide what to fix or build next.