Code 128 vs Code 39: Choosing the Right Linear Barcode
Compare Code 128 and Code 39 barcodes in density, character set, error checking, and industry use. Learn which linear barcode format fits your application.
Code 128 and Code 39 are the two most widely used alphanumeric linear barcode formats. Both encode letters and numbers. Both scan with standard equipment. Both have decades of proven reliability. But they make fundamentally different trade-offs in density, complexity, and character set — and those differences determine which one you should use.
Quick Comparison
| Feature | Code 128 | Code 39 |
|---|---|---|
| Year introduced | 1981 | 1974 |
| Character set | Full ASCII (128 characters) | A-Z, 0-9, 7 special characters |
| Encoding | 3 bars, 3 spaces (11 modules) | 5 bars, 4 spaces (wide/narrow) |
| Density | High | Moderate |
| Check digit | Mandatory (modulo 103) | Optional (modulo 43) |
| Self-checking | No | Yes |
| Numeric mode | Double-density (2 digits per symbol) | Same density as alpha |
| Lowercase | Native | Extended mode only (paired chars) |
| Continuous/Discrete | Continuous | Discrete (inter-character gaps) |
| GS1 variant | GS1-128 | None |
Density: Where Code 128 Wins
Density is Code 128's primary advantage. The same data encoded in Code 128 produces a shorter barcode than Code 39. This matters when label space is limited.
Alphanumeric data: Code 128 is approximately 30-40% more compact than Code 39. A 10-character string like "WAREHOUSE1" takes roughly 35mm in Code 128 versus 55mm in Code 39 (at 0.25mm X-dimension).
Numeric data: The gap widens dramatically. Code 128's Code C subset encodes two digits per symbol character, effectively doubling density for numeric strings. A 10-digit number takes roughly 18mm in Code 128 versus 50mm in Code 39.
The density difference comes from two factors:
-
Code 128 uses continuous encoding — characters share boundaries with no inter-character gaps. Code 39's discrete encoding requires a narrow gap between each character.
-
Code 128 uses more efficient module patterns — each character is encoded in 11 modules (3 bars + 3 spaces). Code 39 uses 9 elements per character, but the wide/narrow binary encoding wastes space compared to Code 128's multi-width approach.
Practical Impact
On a standard 4" x 6" shipping label, density usually doesn't matter — both formats fit comfortably. But on small labels (asset tags, component labels, narrow shelf tags), Code 128's compact encoding can be the difference between fitting the data and needing a larger label.
Character Set: Full ASCII vs. Alphanumeric
Code 128 encodes all 128 ASCII characters natively through three code subsets:
- Code A: Control characters + uppercase + digits
- Code B: Uppercase + lowercase + digits + symbols
- Code C: Numeric pairs (double density)
The encoder switches between subsets automatically to optimize barcode length. No special configuration is needed.
Code 39 encodes 43 characters: uppercase A-Z, digits 0-9, and seven special characters (space, -, ., $, /, +, %). Lowercase letters and control characters require Extended Code 39, which pairs two standard characters to represent each extended character — doubling the barcode length for those characters.
When this matters: If your data includes lowercase letters, special symbols, or control characters, Code 128 handles them natively. Code 39 can do it through Extended mode, but the space penalty is significant and the host system must interpret the paired characters.
Error Checking Approaches
The two formats take fundamentally different approaches to error detection.
Code 39: Self-Checking
Code 39's bar patterns are mathematically designed so that a single printing defect cannot transform one valid character into another valid character. A bar that prints too wide or a space that shrinks produces an invalid pattern — the scanner returns no result rather than a wrong result.
This self-checking property means Code 39 works without any check digit. The symbology itself prevents single-substitution errors. For many applications, this built-in safety is sufficient.
An optional modulo 43 check digit adds protection against multiple errors and character deletion. Some standards (like the U.S. DoD's MIL-STD-129) mandate this check digit.
Code 128: Mandatory Check Digit
Code 128 is not self-checking. Without error detection, a print defect could potentially produce a wrong but valid character. To compensate, Code 128 requires a mandatory modulo 103 check character.
The check character is calculated by weighting each data character by its position and computing the modulo 103 remainder. This provides strong detection of substitution, transposition, and insertion errors.
Bottom line: Code 39 catches errors through bar pattern design (self-checking). Code 128 catches errors through a mandatory mathematical check character. Both approaches are reliable. Code 128's check character provides slightly stronger multi-error detection, while Code 39's self-checking property means even without a check digit, single errors are caught.
Industry Standards
Certain industries standardize on one format or the other:
Code 39 Standards
- Automotive (AIAG): North American automotive supply chain standardized on Code 39 for parts identification and shipping labels
- U.S. Department of Defense (MIL-STD-129/130): Military logistics and equipment marking use Code 39 with mandatory modulo 43 check digit
- Healthcare (HIBCC): Health Industry Bar Code Council standard uses Code 39 for healthcare product labeling
- NATO: Military logistics across NATO member countries follow Code 39 standards
Code 128 Standards
- GS1-128 (formerly EAN-128/UCC-128): The supply chain standard for encoding structured data (GTINs, dates, batch numbers, serial numbers) uses Code 128 as its base symbology
- ISBT 128: Blood banking standard built on Code 128, replacing the older Codabar system
- Shipping and logistics: FedEx, UPS, USPS, and most carriers use Code 128 or GS1-128 on shipping labels
- General retail logistics: Case labels and pallet labels throughout retail supply chains use GS1-128
If your industry has a standard, follow it regardless of which format you'd prefer technically. Interoperability with supply chain partners matters more than marginal density advantages.
Implementation Considerations
Printing
Both formats print reliably with standard thermal, inkjet, and laser printers. Code 128's narrower bars require slightly better print resolution for small X-dimensions, but at typical label sizes (X-dimension 0.25mm or larger), both formats print equally well.
Code 39's wide/narrow binary encoding is more tolerant of print quality variation because the scanner only needs to distinguish "wide" from "narrow." Code 128's multi-width encoding requires more precise bar widths, making it slightly more sensitive to ink spread and printer resolution at very small sizes.
Scanner Configuration
Both formats are supported by essentially every barcode scanner manufactured in the last 30 years. Scanners auto-discriminate between them using the start/stop character patterns — no manual configuration needed to switch between reading Code 128 and Code 39.
However, some scanner configurations may need attention:
- Code 39 check digit: If your application uses the optional check digit, the scanner may need to be configured to validate and strip it
- Extended Code 39: The scanner must be configured to interpret paired characters as their ASCII equivalents
- Code 128 FNC1: If using GS1-128, the scanner should be configured to recognize the FNC1 function character that identifies GS1 formatting
Software Support
Every barcode library, label design software, and scanning SDK supports both formats. There's no practical difference in software availability or integration effort.
Decision Guide
Choose Code 128 When:
- Space is limited: The density advantage saves significant label real estate
- Data includes lowercase or special characters: Native full ASCII encoding avoids Extended mode penalties
- Data is primarily numeric: Double-density numeric mode in Code C dramatically reduces barcode width
- You're using GS1 standards: GS1-128 is built on Code 128 and is the standard for structured supply chain data
- Building a new system: Code 128 is the better default for new implementations without legacy constraints
Choose Code 39 When:
- Your industry standard requires it: Automotive (AIAG), defense (MIL-STD), or healthcare (HIBCC) specifications mandate Code 39
- Existing infrastructure uses it: The migration cost exceeds the benefits of switching
- Self-checking property is valued: Applications where barcode verification equipment isn't readily available benefit from Code 39's inherent error detection
- Simplicity matters: Code 39's straightforward wide/narrow encoding is easier to implement in custom systems without barcode libraries
- Supply chain partners expect it: If your trading partners' systems are built for Code 39, compatibility trumps density
Either Works Fine When:
- Label space is generous: On standard shipping labels with plenty of room, the density difference is irrelevant
- Data is short alphanumeric: For codes under 10-15 characters of uppercase + digits, both formats produce reasonable barcode sizes
- Standard equipment is used: Both formats scan with the same scanners and print with the same printers
Generating Barcodes
Create barcodes in either format with our free generators:
- Code 128 Generator — enter any text and download as SVG, PNG, or PDF
- Code 39 Generator — enter uppercase alphanumeric data
Both generators handle encoding, check digit calculation, and proper sizing automatically. Download the generated barcode and use it directly in your label design or packaging layout.