What is Code 128?
Code 128 is a variable-length, alphanumeric linear barcode. It was designed to represent the full ASCII character set efficiently by using three selectable character sets, commonly called Code Set A, Code Set B and Code Set C.
The symbol includes a start character, encoded data, a calculated check character and a stop pattern. A scanner decodes the bars and spaces into the original data; the barcode itself normally represents an identifier or transaction value rather than an entire database record.
Code Sets A, B and C
Code 128 can switch between three code sets inside a symbol. That flexibility is one reason it is more compact than many older industrial symbologies.
| Code Set | Best suited for |
|---|---|
| A | Uppercase letters, digits, punctuation and ASCII control characters. |
| B | Uppercase and lowercase letters, digits and punctuation; often the most natural choice for general text. |
| C | Dense numeric data. It represents pairs of digits efficiently and can greatly shorten a numeric symbol. |
AB-10482 is commonly suited to Code Set B. A long even-length numeric identifier may be encoded more compactly with Code Set C.Where is Code 128 used?
Code 128 is a strong general-purpose choice when an organization controls its own labeling system. It is commonly encountered on inventory labels, work-in-process labels, asset tags, warehouse location labels, shipping documents, cartons and internal product identification.
A manufacturer might encode a part number or serial number in Code 128 and use the scan as a database key. A warehouse might use it for a bin location. In each case, the application retrieves the descriptive information after the identifier is scanned.
Advantages
- High data density: It can encode the same value in less horizontal space than many older linear symbologies.
- Broad character support: It can represent uppercase, lowercase, digits, punctuation and control characters.
- Numeric efficiency: Code Set C is especially useful for long numeric strings.
- Widely supported: Industrial barcode scanners and label software commonly support Code 128.
- Built-in error checking: A mandatory check character helps detect decode errors.
Limitations
- As a 1D barcode, the symbol grows wider as more data is added.
- It is generally less appropriate than a 2D symbol when a large amount of data must fit into a very small area.
- A barcode that is generated correctly can still scan poorly if printed with insufficient resolution, contrast, quiet zone or print quality.
Code 128 vs. GS1-128
GS1-128 uses the Code 128 symbol architecture but adds GS1 rules for structured supply-chain data. GS1 Application Identifiers define the meaning of data elements such as a GTIN, serial number, lot number or expiration date. In other words, a scanner may see Code 128 bars in both cases, but GS1-128 carries standardized GS1 semantics and uses a special Function 1 character to identify the GS1 format.
Printing considerations
Reliable scanning depends on the entire print system: printer resolution, chosen X-dimension, print speed, heat or darkness, label surface, ribbon compatibility, bar growth and adequate quiet zones. A damaged thermal printhead can create a vertical void through every bar it crosses, while excessive heat can spread bars and reduce the intended space width.
For production work, “my scanner reads it” should not be treated as proof that a symbol meets a formal quality specification. Barcode verification evaluates characteristics of the printed symbol against an applicable standard.
Frequently asked questions
Can Code 128 contain letters and numbers?
Yes. It is designed for alphanumeric data and can also encode control characters.
Is Code 128 the same as UPC?
No. UPC is a standardized retail identification barcode with a specific data structure. Code 128 is a more flexible general-purpose linear symbology.
Should I use Code 128 or Data Matrix?
Use case, data length, available label area, scanner capability and industry requirements should drive the decision. Code 128 is excellent when a linear symbol fits comfortably. Data Matrix becomes attractive when space is constrained or significantly more data must be carried.