Code 128: The Swiss Army Knife of 1D Barcodes
Everything about Code 128: three code sets (A/B/C), automatic subset switching, FNC1 for GS1-128, and why it dominates shipping and logistics.
Code 128: The Swiss Army Knife of 1D Barcodes
Code 128 is the most versatile linear barcode symbology, capable of encoding all 128 ASCII characters with high density. Defined by ISO/IEC 15417, it is the standard choice for shipping labels, internal tracking, and any application requiring alphanumeric 1D barcodes.
Three Code Sets
Code 128 defines three code sets, each optimized for different character ranges:
- Code Set A: ASCII 0-95 (uppercase letters, digits, control characters)
- Code Set B: ASCII 32-127 (uppercase, lowercase, digits, punctuation)
- Code Set C: Digit pairs 00-99 (double-density numeric encoding)
The barcode can switch between code sets mid-symbol using shift (single character) and latch (all following characters) codes. Smart encoders automatically select the most compact encoding.
Symbol Structure
Each Code 128 symbol contains:
- Quiet zone (10X minimum)
- Start character (Start A, Start B, or Start C)
- Data characters (variable number)
- Check character (Modulo 103)
- Stop character (fixed pattern)
- Termination bar (2-space; the basic unit of barcode width." data-category="Barcode Anatomy & Structure">module bar)
Each character uses 3 bars and 3 spaces within 11 modules (the stop pattern uses 13 modules).
Modulo 103 Check Digit
The check digit calculation: 1. Start value = start character value (103, 104, or 105) 2. Add each data character value multiplied by its position (1, 2, 3...) 3. Divide total by 103; the remainder is the check character value
This weighted algorithm provides excellent error detection, catching 100% of single-character errors and virtually all transpositions.
GS1-128 Mode
When Code 128 starts with GS1-formatted data in barcodes." data-category="GS1 Standards & Identifiers">FNC1 immediately after the start character, it becomes GS1-128 (formerly UCC/EAN-128). This special mode signals that the data contains GS1 Application Identifiers, enabling supply chain data encoding. FNC1 also serves as a separator between variable-length AI fields.
Code 128 vs Other 1D Symbologies
| Feature | Code 128 | Code 39 | EAN-13 |
|---|---|---|---|
| Character set | Full ASCII | A-Z, 0-9, 7 specials | Numeric only |
| Density | High | Low | Fixed |
| Variable length | Yes | Yes | No (13 digits) |
| Self-checking | No | Yes | No |
| Check digit | Mandatory | Optional | Mandatory |
Best Practices
- Use Code Set C for long numeric strings to halve the symbol width
- Let your encoding library handle automatic code set switching
- Ensure minimum quiet zones of 10X on each side
- For GS1 supply chain data, always use GS1-128 (FNC1 prefix) rather than plain Code 128
- Minimum X dimension: 0.25mm for general use, 0.495mm for retail shipping labels