Scanbot SDK has been acquired by Apryse! Learn more

Learn more
Skip to content

Code 39 Barcode Scanner

Add Code 39 scanning to your mobile application or website

Trusted by 300+ global
industry leaders

Volvo Customer Shiseido Customer Coop Naturally logo. Blue coop lettering. PwC Customer TitleMax Customer Procter & Gamble Customer Generali Success Story Deutsche Telekom Case Study Deutsche Bahn Success Story AXA Success Story ArcBest Customer Volvo Customer Shiseido Customer Coop Naturally logo. Blue coop lettering. PwC Customer TitleMax Customer Procter & Gamble Customer Generali Success Story Deutsche Telekom Case Study Deutsche Bahn Success Story AXA Success Story ArcBest Customer

Turn smartphones into fast & reliable Code 39 scanners

The Scanbot Code 39 Barcode Scanner SDK delivers exceptional performance even under challenging conditions – such as code damage or when scanning small codes commonly found in industrial applications like warehousing and manufacturing. With a scanning speed of under 0.04 seconds, your users get instant reads for seamless workflows.

Key benefits include:

  • Offline scanning: The Scanbot SDK works 100% on-device, ensuring both uninterrupted performance and data security.
  • Enterprise support: Questions or requests? Contact our technical support team. We’re happy to assist you.
  • Flat pricing model: Cost stays the same no matter how much your user base or scanning volume grows.
Code 39 barcode scanner app on a phone scanning a patient wristband.
Code 39 barcode reader

How this scanning tool works

Our free online Code 39 barcode reader scans codes directly through your camera or on imported images. This barcode scanner works in any browser, no app download or signup needed. Enjoy real-time camera view scanning or decode barcodes on pictures in seconds – just point your camera at the Code 39 barcode or import an image file to instantly access the encoded data.

This tool is powered by the Scanbot Barcode Scanner SDK!


(We don’t store any images or data you import. Everything stays on your device.)

Understanding Code 39 barcodes

What is a Code 39 barcode?

 

Code 39 is a one-dimensional (1D) barcode symbology standardized in ISO/IEC 16388. Developed in 1974, it was among the first barcodes to support alphanumeric data, including letters, numbers, and some special characters. Code 39 is also known as Code 3 of 9, Alpha39, Type 39, USD-3, and USS Code 39.

 

Each barcode includes start and stop characters (an asterisk) that help barcode scanners identify the code’s boundaries. Additionally, Code 39 includes an optional check character or check digit for enhanced error detection.

 

Code 39 barcodes are easily scanned by most barcode scanners and support manual verification thanks to their text interpretation below the barcode.

 

Code 39 vs Code 39 Extended (Full ASCII)

 

The standard Code 39 supports 43 characters (digits 0-9, uppercase letters A-Z, and seven special characters: -, ., $, /, +, %, and space). Code 39 Extended (also called Full ASCII Code 39) can encode the entire 128-character ASCII set.

Key characteristics of Code 39 Extended:

 

  • Two-character combinations are used to represent characters beyond the basic 43. For example, “+E” is the combination for the lowercase letter “e”.
  • Trade-off: Using these character pairs inevitably increases the barcode length.
  • Less efficient for applications requiring extensive use of lowercase letters or special ASCII characters.

 

Structure and components

 

Code 39 relies on patterns of wide and narrow bars and spaces to encode characters. Each character is represented by 9 elements: 5 bars and 4 spaces. These include 3 wide and 6 narrow elements, corresponding to “3 of 9.”

The symbology can encode 43 characters: numeric digits (0-9), uppercase letters (A-Z), and seven special characters (-, ., $, /, +, %, and space).

 

Code 39 barcodes consist of the following key components:

 

  1. Quiet zones: Blank areas on both sides of the barcode that ensure proper detection and readability.
  2. Start character: An asterisk (*) that indicates the beginning of the barcode.
  3. Data characters: The main content section where information is encoded.
  4. Stop character: An asterisk (*) that indicates the end of the barcode.

 

Code 39 structure

 

Code 39 barcodes typically also show the following characteristics:

 

  • X-dimension: The width of a narrow element (bar or space), typically 4-40 mils
  • Inter-character gap: Space between individual encoded characters, usually equal to one narrow bar width
  • Bar ratio: Relation between narrow and wide elements, often 1:2 to 1:3, with 1:2.5 recommended
  • Self-checking property: Design largely prevents single-character errors from generating valid misreads, enhancing reliability

 

Encoding and error detection

 

Each character pattern is assigned a numeric value, as shown in the table below.

 

Code 39 encoding

 

These values are used to calculate the checksum. This is an optional modulo 10 or 43 check character added to the end of the Code 39 barcode for error detection.

 

Here’s how the checksum is calculated and encoded:

 

  1. Assign numeric values to each character in the data portion of the barcode (using the table).
  2. Sum all those numeric values together.
  3. Divide the sum by 43 (the number of possible values) or 10.
  4. The remainder of that division is the checksum value.
  5. The character corresponding to this value is appended to the barcode.

 

In step 3, the sum of all character values is divided either by 43 (MOD43) or 10 (MOD10).

 

Using Modulo 43 (MOD43), taking the remainder of dividing by 43 as the code checksum, is most common. Since Code 39 encodes 43 characters, this ensures the remainder always maps to a valid character. This provides stronger error detection on alphanumeric data.

 

Modulo 10 (MOD10) produces only numeric check digits between 0 and 9. This is sufficient for numeric-only cases but is otherwise less robust in the case of alphanumerical codes.

For example, some inventory or batch control systems use Code 39 but restrict data to numbers. This is common for carton IDs or shipment batches. In these cases, a simple Modulo 10 checksum is enough to catch common input or scanning errors. The calculation is lightweight because the digits are summed as-is, without need for the lookup table, since digits count as themselves in the checksum calculation.

 

Industry Standards and Compliance

 

Code 39 has been adopted by numerous industry organizations and standardized for specific applications. This ensures interoperability and compliance across sectors.

 

Let’s take a brief look at some of the most important standards:

 

LOGMARS (Logistics Applications of Automated Marking and Reading Symbols):

  • Official standard used by the US Department of Defense (DoD)
  • Defined by Military Standard MIL-STD-1189B and related specifications
  • Mandates specific placement, size, and data encoding requirements for military supply chain items
  • Requires Modulo 43 checksum for enhanced data integrity.

 

HIBCC (Health Industry Business Communications Council):

  • Healthcare industry labeling standard, focused on patient safety
  • Applied to patient wristbands, medication packaging, and surgical instruments
  • Used for unique device identification (UDI) on medical equipment
  • Supports both Code 39 and Code 128 implementations, as well as 2D barcodes.

 

AIAG (Automotive Industry Action Group):

  • Standard for labeling in the automotive manufacturing sector
  • Specifically adopted for VIN (Vehicle Identification Number) barcode encoding
  • Enables continuous part tracking throughout automotive supply chains
  • Facilitates automated assembly line processes and quality control.

 

Code 32 (Italian Pharmacode)

 

Code 32, also called Italian Pharmacode or Codice Farmaceutico, is a specialized variant of Code 39, designed specifically for pharmaceutical product identification in Italy. It encodes the AIC (Autorizzazione all’Immissione in Commercio) identifier.

 

 

Key characteristics of the Italian Pharmacode:

  • Mandated by Italian pharmaceutical regulations for medicine identification and traceability
  • Derived from Code 39 symbols, but with a more limited character set of 32 characters: the digits 0-9 and the English alphabet excluding the letters A, E, I, O
  • The code consists of nine digits, the first of which is zero and the last a check digit
  • The checksum is calculated using MOD10
  • Ensures compatibility with pharmacy IT systems and supports anti-counterfeiting measures.

 

Applications of Code 39 barcodes

 

Manufacturing and automotive

Code 39 is common in the automotive industry and factory automation for tracking components, products, and work-in-progress items. It was also adopted by the Automotive Industry Action Group as the standard VIN Barcode.

 

Healthcare

In the healthcare sector, Code 39 barcodes are used for patient identification, medication management, and equipment tracking. In particular, the Health Industry Bar Code Council (HIBCC) regulates their use on wristbands, medication packaging, and medical devices.

 

Logistics

Code 39 barcodes are widespread in logistics applications, including inventory management, warehouse operations, and shipping processes.

 

Military and government

The United States Department of Defense uses Code 39 under the LOGMARS (Logistics Applications of Automated Marking and Reading Symbols) standard to label supplies and equipment.

 

Code 39 Comparison Table with other popular Barcode types

 

Feature Code 39 Code 128 UPC (UPC-A) Code 93
Character Set 43 chars (0–9, A–Z, 7 symbols) Full ASCII (128 chars) Numeric only 43 characters + full ASCII (128 chars)
Data Density Low High Medium Medium–high
Length Limit No theoretical limit No theoretical limit Fixed (12 digits) No theoretical limit
Checksum Optional (MOD43 / MOD10) Mandatory (MOD103) Mandatory Mandatory, 2× MOD47
HRI Yes Yes Yes Yes
Typical Use Cases Industrial, military, healthcare Retail, shipping, logistics Retail products Postal and logistics
Year Introduced 1974 1981 1973 1982
Print Tolerance High Medium Medium Medium
Scanner Support Universal – typically enabled by default Universal – typically enabled by default Universal – default on POS scanners Universal – enable “Code 93”

 

Code 39 Variants at a Glance Code 39

 

Feature Code 39 Standard Code 39 Extended (Full ASCII) Code 32 (Italian Pharmacode)
Character Set 43 chars (0–9, A–Z, 7 symbols) Full ASCII (128 chars via 2-character combos) 43 chars (0–9, A–Z, 7 symbols)
Data Density Low Lower (longer barcodes due to 2-char encoding) Compact (fixed length)
Checksum Optional (MOD43 / MOD10) Optional (MOD43 / MOD10) Mandatory check digit (MOD10)
Typical Use Cases Industrial, military, healthcare Applications requiring lowercase/special characters (full ASCII) Italian pharmaceutical packaging
Scanner Support Universal – typically enabled by default Universal – enable “Code 39 Full ASCII” Universal – enable “Code 32 / Italian Pharmacode”

 

Why choose the Scanbot SDK for Code 39 scanning?

 

The Scanbot Barcode Scanner SDK is specifically designed to handle the challenges of decoding Code 39 barcodes in real-world scenarios. What sets us apart:

 

  • Exceptional performance: Reliably decodes even damaged, low-contrast or distorted barcodes.
  • High-speed scanning: Read Code 39 barcodes in as little as 0.04 seconds.
  • Cross-platform compatibility: Easily integrate with Android, iOS, cross-platform, web, Windows, and Linux platforms.
  • Customizable UI: Customize the ready-to-use components to match your app or website design.
  • Privacy-first: Operates offline for complete data security.

 

Our SDK supports both standard and Extended Code 39 formats. Once Extended Code 39 is enabled in the configuration, the SDK automatically detects whether a barcode uses standard or extended encoding and decodes the content accordingly.

 

It also supports proper Human Readable Interpretation (HRI) formatting when displaying the result. HRI refers to the text shown below the barcode.

 

For Code 39, specifically, the scanner can output the encoded information with or without the start/stop asterisks or checksum characters. Our SDK conforms to industry standards and regulations (such as LOGMARS for defense or HIBCC for healthcare) to ensure the HRI is displayed consistently and in the required format.

 

Whether your use case involves Code 39 barcodes, QR codes, or any other barcode, the Scanbot SDK delivers the accuracy, speed, and reliability you need to succeed.

 

How to build a Code 39 Barcode Scanner in JavaScript

 

Creating a browser-based Code 39 Barcode Scanner is straightforward. In the following example, we’ll implement it in a single stand-alone HTML file.

 

Scanning a Code 39 barcode

 

To achieve this, we’ll use plain JavaScript and the Scanbot Web Barcode Scanner SDK.

 

First, create an index.html with some boilerplate code.

 

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
        />
        <title>Code 39 Barcode Scanner</title>
    </head>
    <body>    
    </body>
</html>

 

To set up our scanner, we’ll have to do the following:

 

  • Create a button that calls up the scanning interface when clicked.
  • Include a <p> element on the page for displaying the scanning result.
  • Import the Scanbot Web SDK using a CDN.
  • Process the scan result before displaying it on the page.

 

⚠️ In this example, we’re importing the SDK via jsDelivr. However, you should only do this for quick prototyping. In your production environment, please download the Web SDK directly (or install it via npm) and include its files in your project.

 

The result should look something like this:

 

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
        />
        <title>Code 39 Barcode Scanner</title>
    </head>

    <body style="margin: 0">
        <button id="start-scanning">Start scanning</button>
        <p id="result"></p>
        <script type="module">
            import "https://cdn.jsdelivr.net/npm/scanbot-web-sdk@7.0.0/bundle/ScanbotSDK.ui2.min.js";
            const sdk = await ScanbotSDK.initialize({
                enginePath:
                    "https://cdn.jsdelivr.net/npm/scanbot-web-sdk@7.0.0/bundle/bin/barcode-scanner/",
            });
            document
                .getElementById("start-scanning")
                .addEventListener("click", async () => {

                    const config =
                        new ScanbotSDK.UI.Config.BarcodeScannerScreenConfiguration();

                    const scanResult = await ScanbotSDK.UI.createBarcodeScanner(config);
                    if (scanResult?.items?.length > 0) {
                        document.getElementById("result").innerText = scanResult.items[0].barcode.text;
                    } else {
                        document.getElementById("result").innerText = "Scanning aborted by the user";
                    }
                });
        </script>
    </body>
</html>

 

💡 We use Web Barcode Scanner SDK version 7.0.0 in this tutorial. You can find the latest version in the changelog.

 

This already provides us with a fully functional barcode scanner that will read any barcode type. Restricting it to scanning only Code 39 prevents unintended scans and improves the scanner’s performance, as it doesn’t need to check each supported symbology.

 

So let’s restrict scanning to the Code 39 symbology by modifying the BarcodeScannerScreenConfiguration we assigned to the config constant in the previous step.

 

config.scannerConfiguration.barcodeFormats = ["CODE_39"];

 

You can also change the viewfinder’s aspect ratio. It’s square by default, but since Code 39 comes in a horizontal format, it makes sense to also convey this in the scanning interface. This is mainly a cosmetic change, but do keep in mind that only barcodes located inside the viewfinder will be scanned.

 

config.viewFinder.aspectRatio.height = 1;
config.viewFinder.aspectRatio.width = 2;

 

Your final index.html will look like this:

 

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
        />
        <title>Code 39 Barcode Scanner</title>
    </head>

    <body style="margin: 0">
        <button id="start-scanning">Start scanning</button>
        <p id="result"></p>
        <script type="module">
            import "https://cdn.jsdelivr.net/npm/scanbot-web-sdk@7.0.0/bundle/ScanbotSDK.ui2.min.js";
            const sdk = await ScanbotSDK.initialize({
                enginePath:
                    "https://cdn.jsdelivr.net/npm/scanbot-web-sdk@7.0.0/bundle/bin/barcode-scanner/",
            });
            document
                .getElementById("start-scanning")
                .addEventListener("click", async () => {

                    const config =
                        new ScanbotSDK.UI.Config.BarcodeScannerScreenConfiguration();
                    config.scannerConfiguration.barcodeFormats = ["CODE_39"];

                    const scanResult = await ScanbotSDK.UI.createBarcodeScanner(config);
                    if (scanResult?.items?.length > 0) {
                        document.getElementById("result").innerText = scanResult.items[0].barcode.text;
                    } else {
                        document.getElementById("result").innerText = "Scanning aborted by the user";
                    }
                });
        </script>
    </body>
</html>

 

Now run the app and scan a Code 39 to test your scanner!

 

Scanning a Code 39 barcode

 

💡 You can run the Scanbot SDK for 60 seconds per session without a license. For more in-depth testing, we recommend you generate a free trial license.

 

For more information on how to customize your scanner, head over to the documentation.

 


 

Related Barcode Types:

 

Frequently Asked Questions

What is the difference between UPC and Code 39?

UPC (Universal Product Code) and Code 39 serve different purposes and have distinct capabilities:

UPC Characteristics:

- Character support: Numeric digits only (0-9)
- Length: Fixed 12-digit format (UPC-A) or 8-digit (UPC-E)
- Primary use: Retail point-of-sale systems
- Data structure: Product identification with manufacturer and item codes
- Checksum: Mandatory check digit for error detection

Code 39 Characteristics:

- Character support: Alphanumeric (0-9, A-Z) plus 7 special characters
- Length: Variable length with no theoretical limit
- Primary use: Industrial applications, inventory tracking, identification
- Data structure: Flexible
- Checksum: Optional MOD43 or MOD10 check character

How do you create a Code 39 barcode?

Creating a Code 39 barcode involves several steps. This is usually handled automatically by software tools, but you can also create them manually.

Manual creation:
1. Add start character: Begin with an asterisk (*)
2. Enter data: Input your alphanumeric content (uppercase letters, numbers, allowed symbols)
3. Add checksum character (optional): Use the character value table for the MOD43/MOD10 calculation, map the remainder back to a Code 39 symbol, and append that symbol to your data
4. Add stop character: End with an asterisk (*)
5. Apply barcode font: Use a Code 39 font to convert the text to a barcode

Alternatively, you can use tools like the Scanbot Free Online Barcode Generator.

There are a few important printing considerations:
1. Maintain proper quiet zones (minimum 10 narrow spaces on either side)
2. Use correct bar width ratio (1:2.5 recommended)
3. Ensure adequate print resolution for reliable scanning
4. Test barcodes with the target scanning equipment before roll-out

What is the difference between a Code 39 and Code 128 barcode?

Code 39 encodes fewer characters and is less dense, while Code 128 supports a larger character set and is more compact, allowing for higher data density.

What are the limitations of Code 39 barcodes?

Code 39 has limited character support, encoding only uppercase letters, numbers, and a few symbols. It also has lower data density compared to barcodes like Code 128, which can encode more characters in a smaller space.

How could Scanbot SDK help you with Code 39 barcode scanning?

The Scanbot Code 39 barcode scanner delivers exceptional performance in challenging environments, including damaged or curved barcodes, with a scanning speed of under 0.04 seconds for seamless workflows. Try it now with a free trial license.

What is LOGMARS and how does it relate to Code 39?

LOGMARS (Logistics Applications of Automated Marking and Reading Symbols) is the barcode standard adopted by the US Department of Defense. It specifies the use of Code 39 with MOD43 checksums and strict formatting rules. This barcode system ensures all supplies, equipment, and parts in the military supply chain are labeled consistently.
Example: A spare part receives a standardized Code 39 barcode label that any DoD system can scan and interpret.

LOGMARS, AIAG, HIBCC and other barcode standards are fundamental to modern business operations. They guarantee that barcodes are not just scannable, but also meaningful and interoperable across entire industries.

What is HIBCC and how does it relate to Code 39?

HIBCC (Health Industry Business Communications Council) defines how Code 39 barcodes are applied in healthcare. They are used on patient wristbands, medication packaging, and surgical instruments. The use of HIBCC Code 39 barcodes enhances patient safety and compliance with the FDA’s Unique Device Identification (UDI) requirements.
Example: A hospital scans a patient’s Code 39 wristband barcode to instantly access their electronic health record.

What is AIAG and how does it relate to Code 39?

AIAG (Automotive Industry Action Group) publishes barcode standards for the automotive supply chain. Code 39 is mandated for Vehicle Identification Numbers (VINs) and parts tracking, ensuring compatibility across manufacturers and suppliers.
Example: An automotive plant scans Code 39 VIN barcodes during assembly to track parts and streamline quality control.

What are the Advantages of the Code 39 barcodes?

1. Ease of printing: Code 39 uses only two different bar widths (wide and narrow), making it highly lenient for printing on various surfaces.
2. Error detection: Code 39's self-checking and optional checksum enable basic error detection, but no error correction.
3. Scalability: Code 39 can hold alphanumeric data and has no length limit, making it useful for a variety of applications.
4. Omnidirectional scanning: The asymmetric start and stop character enables decoding from any angle.
5. Universal readability: Most 1D barcode scanners can read Code 39 by default (this does not apply to Code 39 Extended).

What are the Disadvantages of Code 39 barcodes?

Code 39 is one of the oldest barcode symbologies. While it remains widely supported and used, it's important to consider its limitations in modern applications:
- Lower data density: Code 39 requires more space than newer symbologies, especially the Extended variant
- Limited character set: Standard variant doesn't support lowercase letters
- Space-constrained layouts: If area is fixed and the payload is the same, use a higher-density symbology (e.g., Code 128, QR/Data Matrix)
- Higher data capacity needs: If the payload itself grows, prefer Code 128 or a 2D code that can carry more.

How to troubleshoot common Code 39 Scanning issues?

Even with robust scanning technology, certain conditions can affect Code 39 barcode readability. Here are the most common issues and their solutions:

1. Start/Stop Character Problems:
- Issue: Scanner reads data but includes asterisk characters in output
- Solution: Configure scanner to strip start/stop characters from output

2. Print Quality Issues:
- Issue: Poor bar edge definition or incorrect bar width ratios
- Solution: Verify printer resolution and bar width ratio (1:2.5 ratio recommended)
- Prevention: Use high-quality thermal transfer printing for critical applications

3. Quiet Zone Violations:
- Issue: Text or graphics too close to barcode edges
- Solution: Design labels with adequate margins (minimum 10 narrow bar widths) on both sides

4. Environmental Scanning Challenges:
- Lighting: Ensure adequate illumination (minimum 300 lux)
- Positioning: Keep skew angle under 45 degrees
- Distance: Stay within optimal scanning range (typically 2 to 20 inches)
- Surface: Avoid curved surfaces that distort bar patterns

Issues specific to Code 39 Extended:
- Scanner configuration: Ensure scanner is programmed to decode Extended format
- Length limitations: Be aware that Extended format significantly increases barcode length
- Character mapping: Verify proper decoding of two-character combinations.

Experience our demo apps

Barcode Icon Art

Barcode Scanner SDK

Scan 1D and 2D barcodes reliably in under 0.04s. Try features like Batch Scanning, Scan & Count, and our AR Overlays.

Launch Web Demo

Scan the code to launch the web demo on your phone.

Web QR Code

Also available to download from:

Document Icon Art

Document Scanner SDK

Scan documents quickly and accurately with our free demo app. Create crisp digital scans in seconds.

Launch Web Demo

Scan the code to launch the web demo on your phone.

Black and white QR code. Scan this code for quick access to information.

Also available to download from:

Data_capture Icon Art

Data Capture Modules

Try fast, accurate data capture with our demo app. Extract data from any document instantly – 100% secure.

Launch Web Demo

Scan the code to launch the web demo on your phone.

Black and white QR code. Scan this quick response code with your smartphone.

Also available to download from: