Barcode Formats Explained: EAN-13, Code 128, and More
You scan a barcode at the grocery checkout and it takes 200 milliseconds to ring up the item. Behind that scan lies a surprisingly deep system of encoding standards, error detection algorithms, and international coordination that has been evolving since the first UPC barcode was scanned on a pack of Wrigley's chewing gum in 1974. Understanding how barcode formats work helps you choose the right one for your product, warehouse, or software project.
How 1D Barcodes Encode Data
A one-dimensional barcode encodes information in the widths of parallel bars and spaces. The scanner reads variations in reflected light as the beam crosses the pattern. Each format defines a specific alphabet of characters, a start/stop pattern, and usually a check digit algorithm.
The key constraint is data density vs. character set. Numeric-only formats like EAN-13 pack more digits per centimeter because each digit maps to a 7-module pattern (a module is the narrowest bar unit). Alphanumeric formats like Code 39 need wider patterns per character because they encode more symbols — uppercase letters, digits, and a handful of special characters.
EAN-13 and UPC-A: The Retail Standard
EAN-13 (European Article Number) and UPC-A (Universal Product Code) are the global standards for retail point-of-sale. UPC-A is a subset of EAN-13 — every UPC-A code is also a valid EAN-13 with a leading zero. Together they cover over 100 countries through the GS1 system.
- EAN-13 — 13 digits: 2-3 digit country prefix + company prefix + item reference + check digit. Managed by GS1. Required for products sold in most international markets.
- UPC-A — 12 digits: dominant in the US and Canada. Same structure minus the leading digit. Over 1 million companies worldwide hold GS1 prefixes.
- EAN-8 — 8 digits: a compact version for small packages where a full EAN-13 would not physically fit (e.g., chewing gum packs, lipstick tubes).
The check digit uses a weighted modulo-10 algorithm. Odd-position digits are weighted by 1, even-position by 3. The check digit makes the total sum a multiple of 10. This catches 100% of single-digit errors and about 90% of adjacent transposition errors.
Code 128: The Versatile Workhorse
Code 128, defined in ISO/IEC 15417, is the most widely used barcode format outside of retail checkout. It encodes the full ASCII character set (128 characters) and offers three sub-codebooks:
- Code 128A — uppercase letters, digits, control characters.
- Code 128B — uppercase and lowercase letters, digits, common symbols.
- Code 128C — numeric pairs (00-99), making it extremely compact for digit-only data.
A single Code 128 barcode can switch between sub-codebooks mid-stream using shift characters. This flexibility is why shipping labels (GS1-128), inventory systems, and healthcare applications all rely on Code 128. FedEx, UPS, and most postal services use Code 128 or its GS1-128 variant for package tracking.
Code 39, ITF-14, and Other Formats
Code 39 (ISO/IEC 16388) was the first alphanumeric barcode, developed in 1974. It is self-checking — no check digit is strictly required — which made it popular in automotive (AIAG standards) and defense (MIL-STD-1189). The trade-off is low density: it needs about 60% more space than Code 128 for the same data.
ITF-14 (Interleaved 2 of 5) encodes exactly 14 digits and is the standard for outer carton identification in logistics. The "interleaved" design encodes digit pairs — one in bars, one in spaces — achieving higher density than standalone numeric codes.
MSI (Modified Plessey) is used primarily in warehouse shelving and inventory management. It encodes digits only and typically includes a Mod 10 check digit.
Choosing the Right Format
The format choice depends on three factors: what you are encoding, where the barcode will be scanned, and industry requirements.
- Retail products — EAN-13 or UPC-A. Non-negotiable for point-of-sale systems. Requires a GS1 company prefix ($250/year in the US).
- Shipping and logistics — Code 128 (GS1-128) for tracking numbers. ITF-14 for carton identification.
- Internal inventory — Code 128 for alphanumeric IDs, MSI for numeric shelf labels.
- Government and defense — Code 39 per MIL-STD-1189, though many agencies are migrating to Code 128.
- High-density or mobile scanning — consider QR codes or Data Matrix, which encode more data in less space and tolerate partial damage.
Print Quality and Scanning Reliability
A technically correct barcode can still fail to scan if printed poorly. The ISO/IEC 15416 standard grades barcode print quality from A (best) to F (fail) based on reflectance, edge contrast, modulation, and quiet zone compliance. Key guidelines:
- Quiet zones — the blank space before and after the barcode must be at least 10x the narrowest bar width. Most scan failures in practice come from insufficient quiet zones.
- Minimum bar width — for laser scanners at checkout distance, the X-dimension (narrowest bar) should be at least 0.264 mm (EAN/UPC standard). Thermal printers can achieve this; inkjet printers may struggle.
- Contrast — black bars on white background is the most reliable. Avoid red or dark blue backgrounds — most laser scanners use red light (633-670 nm) and cannot distinguish red from white.
Key Takeaways
- EAN-13 and UPC-A are mandatory for retail and require a GS1 prefix.
- Code 128 is the default choice for shipping, logistics, and general alphanumeric encoding.
- Check digits catch single-digit and most transposition errors but are not error-correcting — damaged barcodes fail to scan rather than returning wrong data.
- Print quality matters as much as format choice. Insufficient quiet zones are the most common cause of scan failures.
- For data-dense or damage-resistant needs, 2D formats like QR codes are increasingly replacing 1D barcodes.
Need to generate a barcode? Use our Barcode Generator to create Code128, EAN-13, UPC-A, and other formats instantly — download as SVG or PNG, ready for print or digital use.
Frequently Asked Questions
- What is the difference between EAN-13 and UPC-A?
- UPC-A uses 12 digits and is dominant in the US and Canada. EAN-13 uses 13 digits and is the international standard. Every UPC-A code is also a valid EAN-13 with a leading zero. Both require a GS1 company prefix.
- Can barcodes contain letters and special characters?
- It depends on the format. Code 128 encodes the full ASCII character set including letters, digits, and symbols. EAN-13 and UPC-A encode digits only. Code 39 encodes uppercase letters, digits, and seven special characters.
- Why does my barcode fail to scan?
- The most common cause is insufficient quiet zones — the blank space before and after the barcode. Other causes include low print contrast, damaged bars, and printing below the minimum bar width (0.264 mm for EAN/UPC). ISO 15416 defines the grading criteria.