Skip to content
Mohamed Safouan Besrour edited this page Jan 22, 2021 · 11 revisions

Step 1. Download the library.

Option 1: Download from the releases page
Option 2: Download with npm (npm install jsbarcode --save)
Option 3: Download with bower (bower install jsbarcode --save)

Step 2. Include the library.

<head>
	<script src="JsBarcode.all.min.js"></script>
</head>

Or via CDN

<head>
	<script src="https://unpkg.com/jsbarcode@latest/dist/JsBarcode.all.min.js"></script>
</head>

Step 3. Create a canvas or an image.

<canvas id="canvas"></canvas>
<!-- or -->
<img id="barcode"/>
<!-- or -->
<svg id="barcode"></svg>

Step 4: Ready to generate.

If you are using vanilla Javascript:

// By using querySelector
JsBarcode("#barcode", "Hi!");

// or by passing an element variable
var element = document.getElementById("barcode");
JsBarcode(element, "Hi!");

If you are using jQuery:

$("#barcode").JsBarcode("Hi!");