🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

jsbarcode

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
J

jsbarcode

JsBarcode is a customizable barcode generator with support for multiple barcode formats.

3.12.1
latest
100

Supply Chain Security

100

Vulnerability

100

Quality

82

Maintenance

100

License

Version published
Maintainers
1
Created
Issues
132

What is jsbarcode?

The jsbarcode npm package is a versatile library for generating barcodes in various formats. It supports multiple barcode types and can be used in both Node.js and browser environments. The package is highly customizable, allowing users to adjust the appearance and format of the generated barcodes.

What are jsbarcode's main functionalities?

Generate Barcode in HTML

This feature allows you to generate a barcode and embed it in an HTML image element. The code uses the 'canvas' module to create a canvas element, which is then used by JsBarcode to draw the barcode.

const JsBarcode = require('jsbarcode');
const { createCanvas } = require('canvas');

const canvas = createCanvas();
JsBarcode(canvas, '123456789012', { format: 'CODE128' });
console.log('<img src="' + canvas.toDataURL() + '" />');

Generate Barcode in SVG

This feature allows you to generate a barcode in SVG format. The code uses the 'xmldom' module to create an SVG document, which is then used by JsBarcode to draw the barcode.

const JsBarcode = require('jsbarcode');
const { DOMImplementation, XMLSerializer } = require('xmldom');

const document = new DOMImplementation().createDocument(null, 'svg', null);
const svgNode = document.documentElement;
JsBarcode(svgNode, '123456789012', { format: 'CODE128' });
const svgString = new XMLSerializer().serializeToString(svgNode);
console.log(svgString);

Customizing Barcode Appearance

This feature allows you to customize the appearance of the barcode. You can change the line color, width, height, and whether to display the value below the barcode.

const JsBarcode = require('jsbarcode');
const { createCanvas } = require('canvas');

const canvas = createCanvas();
JsBarcode(canvas, '123456789012', {
  format: 'CODE128',
  lineColor: '#0aa',
  width: 4,
  height: 40,
  displayValue: true
});
console.log('<img src="' + canvas.toDataURL() + '" />');

Other packages similar to jsbarcode

FAQs

Package last updated on 10 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts