Code 128 Barcode Generator
The general-purpose linear barcode. It encodes the full range of keyboard characters densely, which is why it turns up wherever a barcode has to carry something other than a product number.
Its numeric subset packs two digits into the space of one character, which makes it the compact choice for reference numbers and much of why it displaced older formats. It has no fixed size, so the label has to be designed around whatever your data produces, and shorter data is the only real lever on width.
- Inventory and asset tags
- Order and reference numbers
- Logistics
- Internal tracking
Preview
Format Guide
CODE 128 — High-density barcode for alphanumeric data.
Any characters
What is Code 128?
Code 128 is the general-purpose linear barcode. It encodes all 128 ASCII characters using three subsets (A for control characters and uppercase, B for the full mixed-case set, C for pairs of digits), and the encoder switches between them mid-symbol to keep the result as short as possible. That subset C trick is why it is roughly twice as dense as Code 39 for numeric data, and why it displaced older formats almost everywhere a barcode has to carry something other than a product number.
Technical characteristics
- Character set
- All 128 ASCII characters
- Length
- Variable
- Subsets
- A, B and C, switched automatically to minimize symbol width
- Check digit
- Modulo 103, calculated by the encoder
- Density
- Subset C encodes two digits per symbol character
Three character sets, and an encoder that switches between them
Code 128 does not have one alphabet, it has three, and a symbol can move between them partway through. Subset A covers uppercase and control characters, B covers upper and lower case, and C does nothing but digits, taken two at a time.
| Subset | Holds | Cost per character |
|---|---|---|
| A | Digits, uppercase, control characters | One symbol character each |
| B | Digits, upper and lower case, punctuation | One symbol character each |
| C | Digits only, in pairs | One symbol character per two digits |
Subset C is the reason Code 128 is the dense option for numbers. A twelve-digit value occupies six symbol characters rather than twelve, halving the width. A good encoder starts in whichever subset suits the beginning of your data and switches when the content changes, so a reference like AB1234567890 is encoded partly in B and partly in C without you asking.
Working out how wide it will be
Unlike EAN-13, Code 128 has no fixed size, so the label has to be designed around whatever the data produces. The arithmetic is simple enough to do before you commit to a label.
The practical consequence is that shortening the data is the only real lever on width. Dropping a fixed prefix that every one of your labels carries anyway saves more millimeters than any amount of tuning at the printer.
Code 128 FAQs
Do I need to choose a subset?
No. The encoder picks the subsets and switches between them to produce the shortest symbol for what you typed.
Code 128 or Code 39?
Code 128 for almost anything new: it is denser, handles lowercase and the full ASCII range, and produces a shorter barcode. Code 39 remains where an existing system or standard requires it.
Is GS1-128 the same thing?
GS1-128 is Code 128 carrying GS1 Application Identifiers, marked by an FNC1 in the first position. Same bars, extra rules about the data.
Why does the barcode get so wide with a long value?
Because Code 128 spends bars per character, so width grows with the data. Digits are the exception worth knowing: the encoder can pack a pair of digits into one symbol character, so a numeric value is close to half the width of the same length of letters. If a label is running out of room, shortening the value — or making it numeric — does more than shrinking the bar width, which only costs you scan reliability.