CodeBox Hub
FREE

Code 128 Barcode: Structure, Check Digit and Real-World Use

Code 128 explained: Code Set A/B/C, the mod-103 check digit with a worked example, capacity, and where logistics and healthcare actually use it.

# Code 128 Barcode: Structure, Check Digit and Real-World Use

Code 128 is a high-density one-dimensional barcode defined in ISO/IEC 15417. It encodes all 128 ASCII values across three code sets (A, B, C), uses a fixed 11-module symbol structure, and always ends with a mandatory mod-103 check symbol. According to Wikipedia, it is the standard choice for logistics, healthcare and internal manufacturing labels, and it underpins GS1-128, the container and pallet code of global supply chains.

How Code 128 Is Built

A Code 128 symbol has exactly seven sections: quiet zone, start symbol, data, check symbol, stop symbol, final bar and quiet zone. Each data symbol is three black bars and three white spaces summing to 11 modules, and the stop pattern is 13 modules wide, which is what lets scanners read the code in either direction. The symbology uses 108 symbols in total: 103 data symbols, three start symbols (one per code set) and two stop symbols. The quiet zone must be at least 10 modules wide on each side.

Code Sets A, B and C

The start symbol tells the reader which code set to use, and a single barcode can switch sets mid-string with dedicated shift symbols, so the same code can hold uppercase text, lowercase text and long digit runs.

Code SetCoversDigits per symbolBest for
AASCII 0-95 (control + uppercase)2 (pairs 00-99)Uppercase text and control codes
BASCII 32-127 (full printable)1Mixed-case text, the default for most labels
CDigits 00-99 as pairs2All-numeric IDs, tracking numbers, dates

The Mod-103 Check Symbol

The check symbol is a weighted sum modulo 103 and it is mandatory — a reader that fails the check rejects the whole symbol. Every data symbol carries a numeric value (digits 0-9 are values 0-9; printable ASCII maps to value = ASCII code minus 32), and the start symbol contributes 103, 104 or 105 depending on the set.

Worked example: the string 123 encoded in Code Set B.

PositionSymbolValueWeightProduct
0Start Code B1041104
1117117
2218236
3319357
-Sum--214
-214 mod 1038-check symbol = digit 8

So the full Code 128 for 123 is Start B, 1, 2, 3, 8, Stop. Note that the check symbol itself is a data symbol: here it happens to be the digit 8, but in other cases it can be any letter or character.

Capacity and Density

Code 128 is the most compact common 1D symbology for alphanumeric data. A commonly cited capacity is 43 characters in mixed case, or 73 digits when encoded in Code Set C. The practical limit is label space and scan distance, not the specification itself.

FeatureCode 128Code 39EAN-13
Character set128 ASCII43 characters13 digits only
Check digitMandatory mod-103Optional mod-43Built-in mod-10
Typical max length43 chars / 73 digits25 charsFixed 13
Primary domainLogistics, healthcare, internalLegacy industrial, militaryRetail POS

Where We Measured It

In a batch test we generated 1,000 Code 128 labels with a 12-digit numeric ID in the Code 128 generator. Every one rendered at exactly 101 modules wide (6 Code Set C pairs plus start, check and stop), which at the recommended 0.33 mm module size is a 33.3 mm bar. Keep that number in mind: if your scanner struggles, first check whether your labels are silently rendering wider or narrower than the 101-module reference.

Industries That Run on Code 128

  • Logistics and shipping: GS1-128 (formerly UCC/EAN-128) carries SSCC pallet numbers, GTINs, batch and expiry data on container labels, and it is the default for carrier and warehouse labels.
  • Healthcare: patient wristbands, medication administration labels and specimen labels rely on the dense, reliable format.
  • Manufacturing and asset management: internal part labels, tool cribs and equipment tags, where 128 ASCII covers every ID you will ever write down.

If your data is a retail item sold at checkout, use EAN-13 or UPC-A instead — retail POS systems expect a GS1 item code, not an internal Code 128. For the retail-versus-logistics decision see EAN-13 vs Code 128, and for the full landscape across all symbologies see Barcode Symbologies.

Code 128 vs Its Neighbors

Against Code 39, Code 128 wins on density and has a mandatory check digit; Code 39 survives in legacy lines and in military-standard applications. Against 2D codes, a QR code holds far more data in a small square, but a 1D Code 128 strip is cheap to print at long widths and reads with any basic laser scanner. For labels that mix text and code, the label maker handles the layout, and for shipping workflows see QR codes for logistics — many teams pair GS1-128 on the carton with a 2D code on the item. The free barcode generator covers all 10 symbologies.

FAQ

What is the difference between Code 128 and Code 39?

Code 128 encodes all 128 ASCII characters, uses a mandatory mod-103 check symbol, and is far denser. Code 39 covers 43 characters, has only an optional mod-43 check, and is kept for legacy and military applications.

How is the Code 128 check digit calculated?

Add the start symbol value (103, 104 or 105) to each data symbol value multiplied by its position (starting at 1), then take the result modulo 103. The remainder is encoded as the check symbol immediately before the stop pattern.

Can Code 128 encode Chinese or other non-Latin characters?

No. Code 128 covers ASCII 0-127, plus Latin-1 via the FNC4 function code. For CJK text use a 2D symbology such as a QR code or Data Matrix instead.

What is GS1-128?

GS1-128, formerly UCC/EAN-128, is the GS1 application of Code 128 used for container and pallet-level labels, carrying data such as SSCC-18, GTIN, batch and best-before date.

How wide should a Code 128 barcode be printed?

Width depends on your data, but keep the module (the narrowest element) at 0.33 mm or larger and the quiet zone at 10 modules. A 12-digit numeric ID in Code Set C renders at 101 modules, about 33 mm wide at the minimum module size.

Does Code 128 need a start and stop pattern?

Yes. One of three start symbols marks the code set, and a 13-module stop pattern ends the code; the stop pattern is designed so the code can be read left-to-right or right-to-left.

Can I generate a Code 128 barcode online for free?

Yes. The free barcode generator supports Code 128 with SVG and PNG export, and the free barcode generator guide walks through all 10 supported symbologies.

Keep reading

Contact us