Code 39 Barcode Explained
Originally developed in the 1970s, Code 39 encodes numbers, capital letters (A-Z) and some special characters. By using combinations of two symbols the full ASCII character set can be encoded including special characters like currency symbols. If those combinations of symbols are used the code is referred to as Code 39 Extended. The "39" in the symbology's name does not refer to the size of the encodable character set, this is a common misconception. Instead, it's short for "three of nine", from the fact that an individual symbol has nine elements (bars and spaces), three of which are wide. This naming scheme is derived from Code 2-of-5 which has five elements, two of which are wide.
Code 39 is mainly used for warehousing, in Germany and other countries it is also used for pharmaceutical products.
Code 39 at a Glance
Code 39 Sizes, Low Density vs High Density
Code 39 has very lenient specifications and can be created with module widths ranging from 0.1 to over 5mm, same goes for the height of the code. We recommend a module width of 0.5mm and a module height of 20mm for most applications.
Likewise, the ratio of wide to narrow bars can be anywhere between 2.0 and 3.0. Smaller ratios will increase the density of the code (making it smaller for given data) but can make scanning the code more challenging.
A code with a ratio of 2.0 ("High Density" or "HD"):
A code with a ratio of 2.5 ("Medium Density"), best choice for most applications:
A code with a ratio of 3.0 ("Low Density" or "LD"):
Code 39 / Code 39 Extended Bit Pattern
Start / Stop Characters for Code 39
Code 39 uses an identical non-encodable symbol for both start and stop characters. Usually, the barcode generator will add those two characters to the symbol automatically. When using a barcode font for Code 39, the start/stop-character is traditionally mapped to the "*" character. Formatting a string like "*12345*" with a Code 39 barcode font will then create a valid barcode (albeit without check digit). To encode a "*" with Code 39, use the combination "/B" (see table below).
Check Digit for Code 39
Code 39 uses a modulo 43 checksum scheme. The characters are summed up, modulo divided by 43, the reminder is the check character. Any character from the code set can be check character, even letters. A Code 39 without check character encoding "12345":
The same data now with check character ("F"):
When creating Code 39 with a check digit, the check character is usually not transmitted with the actual data. In most cases this behaviour must be activated manually in the barcode scanner. Consult your scanner's manual.
Character Table Code 39 Extended
Code 39 Extended code table. ASCII character to the left, the combination to encode to the right. E.g., to encode a lowercase "a" into the code,
one would have to actually encode "+A":
All Softmatic barcode generators will automatically generate the appropriate two symbol codes if the data contains a character from the extended set, e.g. a small cap letter or a control character.
When using Code 39 Extended the barcode scanner has to convert the encoded character pairs to the intended value. For instance, when the code contains the sequence "+A" the scanner must output "a". For most barcode scanners this conversion has to be enabled manually, consult your scanner's manual.
Code 39 vs Code 128
Another popular choice to encode alphanumeric characters is Code 128. The biggest advantage of Code 128 that it is more compact than Code 39 when encoding small cap letters. Code 39 encoding "ABCabc123":
The same data as a Code 128 symbol (both codes were created with a module width of 0.5mm):
In addition, Code 128 features a very compact purely numeric encoding mode. Code 39 is generally a bad choice for larger amounts of data (the maximum length is around 20 characters). For more info see our comparison Code 128 vs Code 39.
Code 39 in Excel, Word or Google Docs
Code 39 is a good choice for embedding barcodes in your spreadsheet or text document. Applications include catalogs, pricelists, inventories with article numbers or serial numbers. The easiest and most straight forward way of creating Code 39 is with a Code 39 barcode font. As we've seen above, the font can create a valid barcode simply by adding "*" to the data. For creating Code 39 Extended or when a check digit is required, a macro or add-in is needed to do the necessary calculations and data conversion, for example the Softmatic barcode add-in for Excel.
Code 39 Fonts - The Space / Underscore Issue
Special caution is required when encoding data that contains a "space" or "blank", like "CODE 39". In most applications, a blank will be displayed as such, i.e. an empty space, no matter what the font contains at this specific character position. The Softmatic barcode fonts for Code 39 have the bit pattern for the space symbol at the "Underscore" character position (this position was chosen way back in 1991 because the Code 39 character set does not contain the "_"). Hence, to encode "CODE 39" with the font, you'd have to enter "CODE_39". Note that this only applies to font-based barcode creation; the Softmatic barcode extensions and generators do not use barcode fonts and data can be entered as is.
Code 39 Fonts - The Asterisk / Bold Issue
Another delightful pitfall with Code 39 barcode fonts is the auto-formatting that some Microsoft applications perform (namely Word and older versions of Excel): Entering a string like "*12345*" will remove the asterisks and render the text "12345" in bold. Recall that the "*" is the start / stop character of Code 39. Without the asterisk the barcode symbol is not valid and will not scan. Deactivate the respective option in Tools > AutoCorrect > AutoCorrect Options.
Create Code 39 / 39 Extended Barcodes 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 on the Adobe Exchange.
Stand-alone Barcode Generator for Code 39Softmatic BarcodePlus V5 creates Code 39 and will export the barcode as PDF / SVG (resolution-independent vector) oder raster image (PNG, TIFF). The app will automatically select Code 39 Extended if the data requires it:
Bulk Generator for Code 39
For mass creation of Code 39, see BarcodeFactory, Softmatic's bulk barcode generator: