Barcode and Label Software

Barcode Comparison: Code 128, Interleaved 2 of 5, Code 39

Code 128, Interleaved 2 of 5, Code 39 – Which Barcode Is Right for You?

1D Codes Comparison

Code 128, Interleaved 2 of 5, and Code 39 are among the most commonly used one-dimensional barcodes. Each of them offers specific characteristics and advantages that vary in relevance depending on the application.

This guide provides a practical comparison, covering all key aspects to help you choose the barcode type that best fits your requirements.

Supported Characters

Each of the three barcode types has its own set of characters it can encode. Therefore, the selection of a suitable barcode type can be quickly narrowed down based on the characters to be encoded:


The supported characters of the three barcodes are as follows:

Why Not Always Use Code 128?

When considering only the supported characters, Code 128 initially seems to be the optimal choice. However, there are additional criteria that, depending on the application, may favor the other barcode types over Code 128.

1. Space Requirements: Code 128 is compact, but Interleaved 2 of 5 can be even more space-efficient for purely numeric data. In the following image, the sequence "12345678" is encoded three times – all three barcodes use the same module width. (A module is the narrowest bar of a barcode.)

Comparison of Code 128 and Interleaved 2 of 5

2. Error Tolerance: While Code 128 uses four different bar widths, the other two barcodes use only two, meaning a barcode scanner only needs to distinguish between "wide" and "narrow". To optimize this distinction for specific printing conditions, the width ratio of wide to narrow bars can be manually set between 2:1 and 3:1 (see figure above).

3. Robustness: Although the limited range of characters may appear as a disadvantage at first glance, it offers an advantage in terms of robustness. Since the scanner only needs to distinguish between 10 characters (for Interleaved 2 of 5) or 43 characters (for Code 39), the probability of confusion is lower.

4. Printing Requirements: Code 128, by using four different bar widths, places higher demands on print quality. In challenging printing conditions or on uneven surfaces, the simpler structures of Code 39 or Interleaved 2 of 5 may be more reliable.

5. Industry Standards: In some industries, certain barcode types have become established standards. For example, Interleaved 2 of 5 is frequently used in logistics and shipping, while Code 39 is widespread in the automotive industry and healthcare sector. Adhering to these standards can ensure compatibility with business partners and supply chains.

Summary: The various barcode types were optimized for different requirements. While Code 128 offers a wide range of characters, Interleaved 2 of 5 and Code 39 are characterized by greater robustness, simple structure, and error tolerance.

Space Requirements

The space requirement or compactness of a barcode depends on how many characters it can fit in a given area. This also directly determines the maximum length of the data to be encoded.

Below is a comparison of the three barcode types in terms of compactness when encoding the digit sequence "12345678":

Comparison of Code 128, Interleaved 2 of 5, and Code 39

As can be seen from the figure, Interleaved 2 of 5 encodes the number most compactly. This is not surprising as this barcode type was developed and optimized for encoding digits. Code 128 behaves similarly when encoding digits. Like Interleaved 2 of 5, the digits are internally encoded in pairs, which is why both barcodes require only half as much space for purely numeric values.

The compactness advantage of Code 128 over Code 39 becomes much less significant when encoding non-numeric characters, such as the letters "ABCDEFGH":

Comparison of Code 128 and Code 39

It should be noted that the Code 39 and Interleaved 2 of 5 shown above do not use a check digit, making each barcode slightly narrower. On the other hand, the width of the barcode can be further reduced by choosing a lower ratio, for example 2.0:1 instead of the 2.5:1 used here. This will be discussed in more detail in a later section.

Efficient Use of Check Digits

A check digit can be used with all three barcode types. It is appended to the encoded data and serves to ensure the correct reading of the data.

Check Digit

How does a check digit work? – When generating the barcode, the software calculates the check digit based on the data to be encoded using a defined algorithm. When scanning, the barcode scanner uses the same algorithm to independently calculate the check digit. The result is then compared against the check digit in the barcode to verify whether the barcode was read correctly.

While in Code 128 the check digit is an integral part of the barcode and is not displayed in the human-readable text line, with Interleaved 2 of 5 and Code 39 it can be decided on a case-by-case basis whether to use a check digit and if so, whether it should also be visible in the human-readable text line. For the latter two barcode types, the scanner must be configured accordingly so that it knows whether to expect a check digit in the barcode or whether to interpret the last digit as part of the encoded data.

Interleaved 2 of 5:

Here, clever planning is particularly worthwhile when combining compactness and security. As mentioned in an earlier section, this barcode type internally always encodes digits in pairs, which brings the technical limitation that only digit sequences with an even number of positions can be encoded. In practice, this limitation is addressed by having the software prepend a "0" when generating the barcode if the number of digits is odd. The barcode scanner is programmed to remove the "0" when reading the number.

12345  becomes  012345

The sometimes more efficient solution in such cases is to achieve the required even number of positions by using a check digit. This saves the prepending and removing of the "0" and at the same time increases the security of the barcode. Therefore, the combination of an odd number of digits in the data and an activated check digit can be a sensible option when planning the data structure and its encoding in Interleaved 2 of 5.

12345  becomes  123457

Code 39:

Due to a certain built-in redundancy in its internal structure, this barcode offers relatively high error tolerance even without a check digit and is therefore more frequently used without than with a check digit. However, the optional check digit should always be considered when maximum data integrity is required, such as in the labeling of medical devices or safety-critical components.

Code 128 – Practical Application of Variants A, B, and C

Besides Code 128, there are also the labels Code 128 A, Code 128 B, and Code 128 C. Contrary to what one might assume, these are not standalone barcode types, but rather an internal division of the 128 encodable characters of Code 128 into three subsets, also called character sets A, B, and C. This division is primarily a technical necessity that makes the large overall character set possible while maintaining compactness.

From a user perspective, the targeted selection of "A", "B", or "C" is particularly interesting when the data to be encoded should undergo additional validation or when a corresponding specification exists. For example, by choosing "Code 128 C", it can be automatically ensured that the data contains only digits and has an even number of positions. "Code 128 A" ensures that no lowercase letters are present, and so on.

The end result is always a Code 128 barcode that uses only the selected character set internally, yet any barcode scanner still identifies it as a "normal" Code 128.

Below are the three character sets with a complete enumeration of all included characters:

Interleaved 2 of 5 and Code 39 – Choosing the Appropriate Ratio

Unlike Code 128 with its four bar widths, Interleaved 2 of 5 and Code 39, as mentioned earlier, each use only two bar widths – wide and narrow. The ratio between these two widths can be set between 2.0:1 and 3.0:1. This possibility was integrated to improve readability under non-ideal conditions. A scanner should thereby be able to reliably distinguish between "wide" and "narrow" even with damaged, poorly printed, or barcodes applied to uneven surfaces, and correctly read the barcode.

Under optimal printing and scanning conditions, the minimum ratio of 2.0:1 can be selected, especially when only a limited area is available for printing. For less favorable conditions, a higher ratio is recommended to increase reading reliability.

Interleaved 2 of 5 – Optimal Use

In practice, Interleaved 2 of 5 is more frequently used with than without a check digit. If the check digit is omitted, for example due to space constraints, it is advisable to set the scanner to a constant number of expected characters. This is recommended because Interleaved 2 of 5 has an inherent weakness: Since the start/stop patterns are not distinctive, they can be confused with other characters during scanning. If the scanner enters or leaves the barcode at a point that resembles a start or stop pattern, the barcode could be scanned incompletely.

The figure shows how a sequence in the barcode (marked blue on the left) can be mistakenly interpreted as a stop character (marked blue on the right), leading to an incomplete scan:

Short Scan with Interleaved 2 of 5

By configuring the scanner to a fixed character length, the problem of the so-called "short scan" is effectively avoided. The scanner then only accepts scans that exactly match the configured character count and automatically discards incomplete scans.

Short scans occur relatively rarely in practice but cannot be completely ruled out without appropriate countermeasures. The use of a check digit or setting the scanner to a fixed character length therefore offers effective protection with minimal effort.