CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-jsbarcode

JavaScript barcode generator library that creates various types of 1D barcodes with extensive customization options for both browsers and Node.js environments.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

industrial-formats.mddocs/

Industrial and Specialized Formats

JsBarcode supports several specialized barcode formats commonly used in industrial applications, logistics, and specific industry sectors including CODE39, ITF (Interleaved 2 of 5), MSI, and Pharmacode.

Capabilities

CODE39 Barcodes

CODE39 is a widely used alphanumeric barcode format popular in industrial applications, inventory management, and logistics due to its simplicity and self-checking properties.

/**
 * Generate CODE39 barcode
 * @param content - Alphanumeric data (A-Z, 0-9, and special characters)
 */
JsBarcode(element, content, { format: "CODE39" });

Character Set:

  • Letters: A-Z (uppercase only)
  • Digits: 0-9
  • Special characters: - . (space) $ / + %
  • Start/Stop: * (automatically added)

Usage Examples:

// Basic alphanumeric
JsBarcode("#barcode", "PRODUCT123", { format: "CODE39" });

// With special characters
JsBarcode("#barcode", "ITEM-456.789", { format: "CODE39" });

// Spaces allowed
JsBarcode("#barcode", "PART A123", { format: "CODE39" });

// Mixed special characters
JsBarcode("#barcode", "ORDER$100/25+TAX", { format: "CODE39" });

ITF (Interleaved 2 of 5)

ITF encodes pairs of digits in an interleaved pattern, making it highly efficient for numeric data. Commonly used for shipping labels and warehouse applications.

/**
 * Generate ITF barcode
 * @param content - Even number of digits (pairs are required)
 */
JsBarcode(element, content, { format: "ITF" });

Requirements:

  • Must contain even number of digits
  • Digits only (0-9)
  • Minimum 2 digits (1 pair)

Usage Examples:

// Even number of digits
JsBarcode("#barcode", "1234567890", { format: "ITF" });

// Shipping codes
JsBarcode("#barcode", "123456789012345678", { format: "ITF" });

// Warehouse tracking
JsBarcode("#barcode", "20250101", { format: "ITF" }); // Date: 2025-01-01

// Carton numbers
JsBarcode("#barcode", "001234", { format: "ITF" });

ITF-14 (GTIN-14)

ITF-14 is a specialized version of ITF used for encoding GTIN-14 codes, commonly used for shipping containers and case-level identification in retail supply chains.

/**
 * Generate ITF-14 barcode with automatic checksum
 * @param content - 13 or 14 digit GTIN (checksum calculated if 13 digits)
 */
JsBarcode(element, content, { format: "ITF14" });

Usage Examples:

// 13 digits - checksum automatically calculated
JsBarcode("#barcode", "1234567890123", { format: "ITF14" });

// 14 digits - validates existing checksum
JsBarcode("#barcode", "12345678901231", { format: "ITF14" });

// Case codes (GTIN-14)
JsBarcode("#barcode", "2501234567890", { format: "ITF14" });

// Shipping container codes
JsBarcode("#barcode", "1501234567890", { format: "ITF14" });

MSI Barcodes

MSI (Modified Plessey) is a numeric-only format commonly used in inventory control and library systems, with various checksum options for error detection.

/**
 * Generate MSI barcode (no checksum)
 * @param content - Numeric digits only
 */
JsBarcode(element, content, { format: "MSI" });

/**
 * Generate MSI barcode with Mod10 checksum
 * @param content - Numeric digits (checksum automatically added)
 */
JsBarcode(element, content, { format: "MSI10" });

/**
 * Generate MSI barcode with Mod11 checksum  
 * @param content - Numeric digits (checksum automatically added)
 */
JsBarcode(element, content, { format: "MSI11" });

/**
 * Generate MSI barcode with double Mod10 checksum
 * @param content - Numeric digits (double checksum automatically added)
 */
JsBarcode(element, content, { format: "MSI1010" });

/**
 * Generate MSI barcode with Mod11 + Mod10 checksum
 * @param content - Numeric digits (dual checksum automatically added)  
 */
JsBarcode(element, content, { format: "MSI1110" });

Usage Examples:

// Basic MSI (no checksum)
JsBarcode("#barcode", "123456789", { format: "MSI" });

// With Mod10 checksum for error detection
JsBarcode("#barcode", "123456789", { format: "MSI10" });

// With Mod11 checksum (higher error detection)
JsBarcode("#barcode", "123456789", { format: "MSI11" });

// Double Mod10 for maximum reliability
JsBarcode("#barcode", "123456789", { format: "MSI1010" });

// Mod11 + Mod10 combination
JsBarcode("#barcode", "123456789", { format: "MSI1110" });

// Library book tracking
JsBarcode("#barcode", "000123456", { format: "MSI10" });

// Inventory control
JsBarcode("#barcode", "987654321", { format: "MSI1010" });

Pharmacode

Pharmacode is a specialized format used in the pharmaceutical industry for drug packaging and tracking, encoding numbers within a specific range.

/**
 * Generate Pharmacode barcode
 * @param content - Number between 3 and 131070
 */
JsBarcode(element, content, { format: "pharmacode" });

Requirements:

  • Numeric input only
  • Range: 3 to 131,070 (inclusive)
  • Used for pharmaceutical packaging

Usage Examples:

// Basic pharmacode
JsBarcode("#barcode", "12345", { format: "pharmacode" });

// Minimum value
JsBarcode("#barcode", "3", { format: "pharmacode" });

// Maximum value  
JsBarcode("#barcode", "131070", { format: "pharmacode" });

// Pharmaceutical product codes
JsBarcode("#barcode", "98765", { format: "pharmacode" });

// Drug package tracking
JsBarcode("#barcode", "54321", { format: "pharmacode" });

Validation and Error Handling

CODE39 Validation

// Valid characters
JsBarcode("#barcode", "VALID123-.", { 
  format: "CODE39",
  valid: function(isValid) {
    console.log("CODE39 valid:", isValid); // true
  }
});

// Invalid characters (lowercase, special chars)
JsBarcode("#barcode", "invalid@#", { 
  format: "CODE39",
  valid: function(isValid) {
    if (!isValid) {
      console.log("CODE39 allows only: A-Z, 0-9, -.$/+%");
    }
  }
});

ITF Validation

// Valid even-length numeric
JsBarcode("#barcode", "123456", { 
  format: "ITF",
  valid: function(isValid) {
    console.log("ITF valid:", isValid); // true  
  }
});

// Invalid odd-length
JsBarcode("#barcode", "12345", { 
  format: "ITF", 
  valid: function(isValid) {
    if (!isValid) {
      console.log("ITF requires even number of digits");
    }
  }
});

ITF-14 Validation

/**
 * ITF-14 validation
 * @param data - Input string
 * @returns boolean - True if 13-14 digits with valid checksum
 */
// Accepts: /^[0-9]{13,14}$/ with checksum validation for 14-digit codes

MSI Validation

/**
 * MSI validation (all variants)
 * @param data - Input string  
 * @returns boolean - True if contains only digits
 */
// Accepts: /^[0-9]+$/ - any length numeric string

Pharmacode Validation

// Valid range
JsBarcode("#barcode", "12345", { 
  format: "pharmacode",
  valid: function(isValid) {
    console.log("Pharmacode valid:", isValid); // true
  }
});

// Out of range
JsBarcode("#barcode", "2", { 
  format: "pharmacode",
  valid: function(isValid) {
    if (!isValid) {
      console.log("Pharmacode must be between 3 and 131070");
    }
  }
});

Industry-Specific Applications

Manufacturing and Inventory

// Part numbers with CODE39
JsBarcode("#part-barcode", "PART-A123.456", {
  format: "CODE39",
  height: 50,
  width: 2,
  displayValue: true,
  fontSize: 12
});

// Carton tracking with ITF
JsBarcode("#carton-barcode", "123456789012", {
  format: "ITF",
  height: 80,
  width: 3,
  margin: 15
});

Shipping and Logistics

// GTIN-14 for case-level tracking
JsBarcode("#case-barcode", "1234567890123", {
  format: "ITF14",
  height: 100,
  width: 2,  
  displayValue: true,
  textPosition: "bottom"
});

// Shipping container codes
JsBarcode("#container-barcode", "098765432109876543", {
  format: "ITF",
  height: 60,
  width: 2,
  background: "#ffffff",
  lineColor: "#000000"
});

Library and Asset Management

// Library book tracking with MSI
JsBarcode("#book-barcode", "000123456789", {
  format: "MSI10",
  height: 40,
  width: 1,
  fontSize: 10,
  displayValue: true
});

// Asset tags with MSI double checksum
JsBarcode("#asset-barcode", "987654321", {
  format: "MSI1010", 
  height: 30,
  width: 2,
  margin: 5
});

Pharmaceutical Applications

// Drug package codes
JsBarcode("#drug-barcode", "98765", {
  format: "pharmacode",
  height: 30,
  width: 4,
  displayValue: false, // Often no text shown
  background: "#ffffff",
  lineColor: "#000000"
});

// Pharmaceutical batch tracking
JsBarcode("#batch-barcode", "54321", {
  format: "pharmacode",
  height: 25,
  width: 3,
  margin: 2
});

Performance and Best Practices

Format Selection Guidelines

// Choose CODE39 for:
// - Mixed alphanumeric data
// - Industrial environments  
// - Self-checking requirements
// - Legacy system compatibility

// Choose ITF for:
// - Purely numeric data (even length)
// - High-density requirements
// - Shipping/logistics applications
// - Case/carton identification

// Choose MSI for:
// - Library systems
// - Inventory tracking  
// - When specific checksum requirements exist
// - Numeric-only applications

// Choose Pharmacode for:
// - Pharmaceutical packaging
// - Drug identification
// - Regulatory compliance
// - Small package applications

Error Prevention

function generateIndustrialBarcode(data, format) {
  // Pre-validate data format
  const validators = {
    "CODE39": /^[A-Z0-9\-\.\s\$\/\+\%]+$/,
    "ITF": /^[0-9]*$/ && data.length % 2 === 0,
    "MSI": /^[0-9]+$/,
    "pharmacode": /^[0-9]+$/ && parseInt(data) >= 3 && parseInt(data) <= 131070
  };
  
  if (validators[format]) {
    JsBarcode("#barcode", data, {
      format: format,
      valid: function(isValid) {
        if (isValid) {
          console.log(`${format} barcode generated successfully`);
        } else {
          console.error(`Invalid ${format} data: ${data}`);
        }
      }
    });
  } else {
    console.error(`Unsupported format: ${format}`);
  }
}

docs

cli.md

code128.md

configuration.md

ean-upc.md

index.md

industrial-formats.md

tile.json