lindell /JsBarcode

Barcode generation library written in JavaScript that works in both the browser and on Node.js

★ 5,901⑂ 1,112👁 131⑃ 97● 371▤ 82
JavaScriptMITCreated 2011-12-29lindell.me/JsBarcode
下载:JsBarcode v3.12.3JsBarcode-3.12.3 ↓3.12.32026-01-07
+0
日增长
5,901
stars
1,112
forks
131
watchers
97
prs
371
issues
82
releases

README

Introduction
----
JsBarcode is a barcode generator written in JavaScript. It supports multiple barcode formats and works in browsers and with Node.js. It has no dependencies when it is used for the web but works with jQuery if you are into that.



Demo
----
 Barcode Generator
 Simple CodePen Demo
 Settings CodePen Demo

Supported barcodes:
----
 CODE128
   CODE128 (automatic mode switching)
   CODE128 A/B/C (force mode)
 EAN
   EAN-13
   EAN-8
   EAN-5
   EAN-2
   UPC (A)
   UPC (E)
 CODE39
 ITF
   ITF
   ITF-14
 MSI
   MSI10
   MSI11
   MSI1010
   MSI1110
 Pharmacode
 Codabar
 CODE93

Examples for browsers:
----

 First create a canvas (or image)
html









 Simple example:
javascript
JsBarcode("barcode", "Hi!");
// or with jQuery
$("barcode").JsBarcode("Hi!");


 Result:
!Result


 Example with options:
javascript
JsBarcode("barcode", "1234", {
  format: "pharmacode",
  lineColor: "0aa",
  width:4,
  height:40,
  displayValue: false
});

 Result:
!Result


 More advanced use case:
javascript
JsBarcode("barcode")
  .options({font: "OCR-B"}) // Will affect all barcodes
  .EAN13("1234567890128", {fontSize: 18, textMargin: 0})
  .blank(20) // Create space between the barcodes
  .EAN5("12345", {height: 85, textPosition: "top", fontSize: 16, marginTop: 15})
  .render();

 Result:
!Result



 Or define the value and options in the HTML element:
Use any jsbarcode- or data- as attributes where  is any option.
html




And then initialize it with:
javascript
JsBarcode(".barcode").init();


 Result:
!Result



 Retrieve the barcode values so you can render it any way you'd like
Pass in an object which will be filled with data.
javascript
const data = {};
JsBarcode(data, 'text', {...options});

data will be filled with a  encodings  property which has all the needed values.
See wiki for an example of what data looks like.


Setup for browsers:
----
 Step 1:
Download or get the CDN link to the script:

| Name | Supported barcodes | Size (gzip) | CDN / Download |
|------|--------------------|:-----------:|---------------:|
|  All  |  All the barcodes!  |  11.1 kB  |  [JsBarcode.all.min.js][1]  |
|  CODE128  |  CODE128 (auto and force mode)  |  6.3 kB  |  [JsBarcode.code128.min.js][2]  |
|  CODE39  |  CODE39  |  5.1 kB  |  [JsBarcode.code39.min.js][3]  |
|  EAN / UPC  |  EAN-13, EAN-8, EAN-5, EAN-2, UPC (A)  |  6.7 kB  |  [JsBarcode.ean-upc.min.js][4]  |
|  ITF  |  ITF, ITF-14  |  5.1 kB  |  [JsBarcode.itf.min.js][5]  |
|  MSI  |  MSI, MSI10, MSI11, MSI1010, MSI1110  |  5 kB  |  [JsBarcode.msi.min.js][6]  |
|  Pharmacode  |  Pharmacode  |  4.8 kB  |  [JsBarcode.pharmacode.min.js][7]  |
|  Codabar  |  Codabar  |  4.9 kB  |  [JsBarcode.codabar.min.js][8]  |
|  CODE93  |  CODE93  |    |  JsBarcode.code93.min.js  |


 Step 2:
Include the script in your code:


html



 Step 3:
You are done! Go generate some barcodes :smile:

Bower and npm:
----
You can also use Bower or npm to install and manage the library.
bash
bower install jsbarcode --save

bash
npm insta

Top issues

Discussions

Latest release

JsBarcode v3.12.3 v3.12.3 2026-01-07

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON