Label Encyclopedia

Common Barcode Types Code128/EAN/UPC Comprehensive Analysis: Encoding Rules for Every Black Bar

📅 2026-07-16 ✍️ Wuxi Lexiang Printing & Packaging ⏱ 6min read

💡 💡 At a Glance

A comprehensive introduction to the characteristics, applicable scenarios, and selection methods for common barcode types such as Code 128, EAN, and UPC.

Last week, a food-industry client brought me a bag of snacks and asked, "Are the black lines on this bag just printed randomly?"

I asked him to scan the code: his phone beeped, and ¥9.80 popped up.

He said, "That's amazing!"

I said it's not magic—every black line hides a string of numerical code. What you scan out is the essence of the price, the ID number of the product. This article won't cover barcode definitions—instead, it walks you through the encoding rules behind every black line.

1D Barcodes: Digital Codes Hidden in Black Lines

Core principle of traditional 1D barcodes (EAN, UPC, Code128, Code39, ITF-14): alternating black and white bars + numeric encoding. The width of each black bar, spacing, and width of white bars combine to form a digit, ultimately spelling out the country + manufacturer + product + check digit.

EAN-13: The 13-Digit Code

Length: 13 digits

Structure:

First 3 digits: Country code + 4-7 digits: Manufacturer code + 3-5 digits: Product code + 1 digit: Check digit
(690-695 = China) + LeXiang prefix + product number + Mod 10 checksum

Checksum algorithm (Mod 10, weight 3):

  • From right to left, odd positions × 1, even positions × 3, then sum
  • Sum + check digit = a multiple of 10
  • Example: 6901234567890 → (0×1+9×3+8×1+7×3+...+6×3+9×1) mod 10 = 0 ✓

Module structure: Left guard 101 + 6 left-data digits + center guard 01010 + 6 right-data digits + right guard 101 + 13 characters (excluding check digit).

Application: Mandatory for retail in China.

UPC-A: The 12-Digit North American Code

Length: 12 digits

Structure:

1-digit system code + 5-digit manufacturer code + 5-digit product code + 1-digit check digit
(0 = regular) + LeXiang prefix + product number + Mod 10 checksum

Relationship with EAN-13: Adding a leading 0 to an EAN-13 makes it a UPC-A. Therefore, the same barcode can be recognized simultaneously as Chinese (EAN-13) and North American (UPC-A).

Application: Mandatory for Walmart and Amazon US.

Code128: Any ASCII Character

Length: Variable (1-48 ASCII characters)

Structure:

  • Quiet zone + start character (Start A/B/C) + data + check digit + stop character + quiet zone
  • 3 character sets: A (digits + uppercase + control characters), B (digits + upper/lowercase), C (double-digit compression for 00-99)
  • Checksum algorithm: Mod 103 weighted (starting from 1)

Density: Stores 2-3 times more information than Code39 at the same width.

Application: Warehouse management (WMS), logistics tracking, production traceability.

Code39: The Factory Veteran Code

Length: Variable (digits + uppercase letters + 5 special characters)

Structure:

  • Quiet zone + start character * + data + stop character * + quiet zone
  • Each character = 9 elements (5 bars + 4 spaces), 2 wide and 6 narrow

Density: Low, but excellent compatibility (readable by any scanner).

Application: Internal factory traceability, automotive manufacturing, machining.

ITF-14: Dedicated to Cartons

Length: 14 digits

Structure:

  • Left guard + 6 digits + 5 digits + right guard
  • Every 5 digits = 1 group (2 thick bars + 3 thin bars)
  • Check digit = Mod 10 weight 3

Features: Can be printed directly on corrugated board (tolerant of low printing precision).

Application: Outer packaging for logistics cartons.

2D Barcodes: Graphic Codes in Black Squares

1D barcodes can only store 13-30 digits, whereas 2D barcodes (QR, DataMatrix) can store hundreds of characters.

QR Code: 3 Zones + 4 Error Correction Levels

Structure:

  • 3 position detection patterns (triangular positioning)
  • 1 alignment pattern (bottom-right corner)
  • Data area (black/white modules)
  • Format information + error correction code

4 Error Correction Levels (L/M/Q/H):

  • L: ~7% error correction
  • M: ~15% error correction
  • Q: ~25% error correction
  • H: ~30% error correction

Capacity:

  • Level L: max 4296 digits / 7089 characters
  • Level M: max 3391 digits / 5596 characters
  • Level Q: max 2420 digits / 3996 characters
  • Level H: max 1852 digits / 3057 characters

DataMatrix: 2D Compact Code

Structure:

  • L-shaped solid border (positioning)
  • Dashed border (clock)
  • Data area (black and white modules)

Features: Can be as small as 2.5mm × 2.5mm and still be readable.

Applications: PCB boards, electronic components, small medical device traceability.

Comparison Table of 7 Barcode Encodings

BarcodeTypeEncoded CharactersCapacityChecksumScenario
EAN-131D0-913 digitsMod 10China Retail
UPC-A1D0-912 digitsMod 10North America Retail
Code1281DAny ASCII1-48 charactersMod 103Warehousing & Logistics
Code391DNumbers + Letters + 5 Symbols1-43 charactersMod 43Factory Traceability
ITF-141D0-914 digitsMod 10Carton / Outer Case
QR Code2DAny + Chinese Characters7089 charactersLevel 4 Error CorrectionPayment / Marketing
DataMatrix2DAny2335 charactersReed-SolomonElectronics / Medical

If you want to see QR code in practice — refer to how to make a QR code label?, or directly contact a LeXiang Packaging consultant, we'll provide barcode selection + GS1 application guidance within 24 hours.

#Barcode Type #Code128 #EAN-13 #UPC-A #Code39 #ITF-14 #QR Code #DataMatrix #Product Barcode #Industrial Barcode #GS1 Standard #Encoding Rules #LeXiang Packaging

FAQ

What type of barcode is used on product outer packaging?

It depends on the target market. Domestic retail uses EAN-13 (13 digits), North American retail uses UPC-A (12 digits), both based on the GS1 global standard. Before printing barcodes, the buyer must first apply for a company prefix from GS1 China / GS1 US, otherwise the barcode cannot be scanned for pricing.

What is the difference between Code128 and Code39?

Code128 has a higher information density (stores more characters in the same width) and supports the full ASCII character set; Code39 has a lower information density and only supports digits + uppercase letters + a few symbols. Code128 is commonly used for warehouse management barcodes, while Code39 is commonly used for factory internal traceability barcodes.

Do QR codes count as barcodes?

Yes. But strictly speaking, QR codes (QR, DataMatrix) are called 2D barcodes, while traditional EAN/UPC are called 1D barcodes. The difference: 1D barcodes store data in one direction with small capacity; 2D barcodes store data in two directions with large capacity (can store URLs, Chinese characters, hundreds of characters).

What should be noted when printing barcodes?

3 hard indicators: (1) barcode quiet zone (left and right margins) ≥ 10 times the narrowest bar width; (2) sufficient contrast (dark bar PCS value ≥ 75%); (3) after scaling, the minimum module width ≥ 0.19mm, otherwise the scanner cannot read it. The printing house will issue a barcode grade report (A/B/C/D, F indicates failure).

Can misprinted barcodes be corrected?

No. Once a barcode is printed on a product, the entire batch must either be scrapped or covered with stickers (which increases cost and affects appearance). Therefore, sample testing must be done before mass production — use a scanner to test-scan at least 10 times successfully before bulk printing.

Need a Custom Packaging Solution?

Learn more about packaging, or consult directly for a custom solution and quote