Code 128 vs. Code 39 - What are the differences

Code 128 vs Code 39

Code 128 (top) and Code 39 (bottom) are two popular choices for encoding alpha-numeric data and letters in a barcode symbol. On this page we describe the differences between the two symbologies and look at the pros and cons of both barcode types.

Code 128 vs Code 39 at a glance:

Property Code 39 Code 128
Character set A-Z, 0-9, some special chars Full ASCII set
Modes Standard, Extended (Full ASCII) Control characters, Alphanumeric, Numeric Compaction
Check digit Optional Mandatory
Data density Medium High
Scanner compatibility All All
Use with barcode font Easy Requires data conversion and check digit calculation

For further reading, we also have more in-depth articles on both barcode symbologies: Code 39 explained and Code 128 explained.

Comparing the size of Code 128 and Code 39

We begin by looking at the size of individual symbols for different kinds of data. All barcodes below were created with a module height of 15mm and a module width of 0.5mm (a module is the thinnest bar). The output resolution is 150dpi.

Encoding capital letters yields the smallest difference in size. Here is a Code 128 symbol encoding "ABCDEF":

Code 128 encoding capital letters

Code 39 with the same data. The symbol is about 30% wider but still manageable:

Code 39 encoding capital letters

This changes dramatically when we need to encode small caps. Code 128 with "abcdef" has the same size as the large cap barcode:

Code 128 encoding small cap letters

Code 39, however, can't natively encode small caps; instead, the barcode generator has to switch to Code 39 Extended. Here, each letter is encoded with two symbols, resulting in a barcode that is almost twice as wide:

Code 39 encoding small cap letters

This not only takes up much more space on labels and packaging; it can also cause problems during scanning if the barcode is wider than the reading window of the scanner.

Code 128 features a numeric compaction mode. Here, a single symbol within a code encodes two digits. Code 128 with "12345678":

Code 128 encoding numeric data

Code 39, however, can not compress the encoded data. The barcode is considerably larger:

Code 39 encoding numeric data

Conclusion: Code 128 has much higher data density than Code 39 - it can encode more data in a smaller symbol.

Code 128 and Code 39 supported characters sets

Both codes support the full ASCII set of 128 characters including control characters like "TAB", "CARRIAGE RETURN", etc. Natively, Code 39 will only encode letters A-Z, digits 0-9 and a handful of special characters. As illustrated with the small caps above, the symbology requires the use of two symbols per character to encode the full ASCII set (table of Code 39 Extended characters).

Neither code can easily encode accented or diacritic characters ("Umlauts").

Unicode, non-latin, cyrillic, asian scripts with Code 128 and Code 39

Neither code symbology supports encoding Unicode characters or non-latin codepages like cyrillic. Likewise, emojis or similar content can not be encoded. Several 2D barcodes are Unicode capable, popular examples are Datamatrix and QR (cellphone barcode).

Code 128 and Code 39 check digit calculation

Both code symbologies employ a simple check digit calculation algorithm that involves summing up the individual symbols and then modulo divide the sum by some factor. Usually the barcode generator will handle this.

While Code 128 is almost always used with a check digit, Code 39 symbols can be created without one. Code 39 is therefore easy to use with a barcode font, for example in Excel: Enter data, add "*" for start and stop code and format the text with the font. This will yield a valid barcode symbol.

Scanning Code 128 and Code 39

It is safe to assume that all current barcode readers will scan both code symbologies. The same goes for barcode reader apps. If a printed barcode can not be scanned, check this:
  • Make sure that the barcode symbology is actually activated in the barcode scanner. Consult your scanner's manual.
     
  • The print quality must be adequate. For Code 128 and Code 39, a resolution of 150-200dpi or higher is recommended (the sample codes above were created with 150dpi). Also, make sure that the code is not printed too small. The minimum module width (i.e. the width of the narrowest bar) should not be below 0.3 mm. The height should not be below 10 mm. A space (the so called "quiet zone") of at least five to ten millimeters should be left around the code.
     
  • By default, many scanners require a barcode to encode at least four characters. If so, a barcode with only three characters will not scan. Check your barcode scanner's manual.
     
  • With Code 128 almost all barcode readers on the market today will will expect a checksum with the barcode. If the code does not scan you may have created it without a checksum.
     

Create Code 128 and Code 39 in Illustrator, InDesign

Easy to use barcode plug-ins and extensions for Adobe InDesign, Illustrator und Photoshop. For more videos, see the Softmatic Youtube Channel

The Softmatic barcode plug-ins and extensions for InDesign, Illustrator and Photoshop are available from the Softmatic store.

Stand-alone software for Code 128 and Code 39

Softmatic BarcodePlus V5 creates Code 128 and Code 39 and will export the barcode as PDF / SVG (resolution-independent vector) oder raster image (PNG, TIFF). The app will automatically select the appropriate 128 subtype; when using Code 39 the app switches to Code 39 Extended when necessary:



Code 39, Code 128 mass creation

For batch creation of Code 39 / 39 Extended and Code 128, use Softmatic BarcodeFactory V5. The software will create thousands of barcode symbols in seconds, with data coming from the built-in serial number generator, the clipboard or via import from Excel, Numbers or CSV text files: