Code 128 is a high-density linear barcode symbology defined in the international standard ISO/IEC 15417:2007. It is used for encoding alphanumeric or numeric-only data and can represent all 128 characters of the standard ASCII set. By use of an extension symbol (FNC4), it can also encode the Latin-1 characters defined in ISO/IEC 8859-1.
Code 128 was developed by the Computer Identics Corporation in 1981. It generally produces more compact barcodes compared to other methods such as Code 39, particularly when the encoded text contains mostly digits.
Structure
A Code 128 barcode consists of seven sections:
- Quiet zone — a mandatory blank margin (minimum 10 modules wide on each side)
- Start symbol — indicates which code subset (A, B, or C) will be used
- Encoded data — the payload characters
- Check symbol — a mandatory weighted modulo-103 checksum
- Stop symbol — marks the end of the barcode
- Final bar — often considered part of the stop symbol
- Quiet zone
Each symbol in the barcode is composed of three black bars and three white spaces of varying widths, each being 1 to 4 modules wide. The total width of every symbol is fixed at 11 modules. The stop pattern is unique in that it contains four bars (two overlapped symbols) and permits bidirectional scanning.
Subtypes (Code Sets)
Code 128 uses three code sets to cover all 128 ASCII values and to optimize encoding for numeric data:
- 128A (Code Set A) — ASCII characters 00 to 95 (digits 0–9, uppercase letters A–Z, control codes), special characters, and function codes FNC 1–4
- 128B (Code Set B) — ASCII characters 32 to 127 (digits 0–9, uppercase A–Z, lowercase a–z), special characters, and FNC 1–4
- 128C (Code Set C) — Encodes two digits (00–99) with a single code point, plus FNC1. This provides the highest data density for purely numeric strings.
Shift and code-switch symbols allow transitions between the subsets within a single barcode.
Check Digit
The check digit is a weighted modulo-103 checksum. It is calculated by summing the start code value with the products of each encoded symbol's value multiplied by its position weight. The total sum is reduced modulo 103, and the resulting remainder is appended as a checksum symbol immediately before the stop symbol.
GS1-128 (formerly UCC/EAN-128)
GS1-128 is a subset of Code 128 that uses the FNC1 function character at the beginning of the barcode. It is widely used in shipping and packaging industries worldwide for product identification at the container and pallet levels in the supply chain. It incorporates Application Identifiers (AIs) that specify the meaning and format of the data that follows (e.g., batch number, best-before date, serial number).
Applications
Code 128 is extensively used in logistics, transportation, warehousing, and retail supply chains. Its high data density and ability to encode the full ASCII character set make it suitable for labeling shipments, inventory tracking, asset management, and healthcare identification. Among linear barcodes, it is one of the most versatile and widely adopted symbologies.