Gathering detailed insights and metrics for @zxing/browser
Gathering detailed insights and metrics for @zxing/browser
Gathering detailed insights and metrics for @zxing/browser
Gathering detailed insights and metrics for @zxing/browser
react-zxing-scanner
<h1 align="center" style="display: flex; justify-content: center">
ngx-zxing-multicode
A 1D and 2D barcode scanner using HTML5 video element, built using the ZXing library which is really usable
@digitalspace/browser
Digitalspace's fork of ZXing for JS's browser layer.
vue-barcode-qrcode-scanner
A Vue 2 barcode/QR scanner based on https://github.com/olefirenko/vue-barcode-reader
ZXing for JS's browser layer with decoding implementations for browser.
npm install @zxing/browser
Typescript
Module System
Node Version
NPM Version
99.4
Supply Chain
98.6
Quality
78
Maintenance
100
Vulnerability
97
License
TypeScript (68.53%)
JavaScript (26.45%)
HTML (5.02%)
Total Downloads
15,239,102
Last Day
4,766
Last Week
127,541
Last Month
548,411
Last Year
5,920,093
MIT License
245 Stars
191 Commits
44 Forks
8 Watchers
7 Branches
12 Contributors
Updated on Jun 29, 2025
Minified
Minified + Gzipped
Latest Version
0.1.5
Package Id
@zxing/browser@0.1.5
Unpacked Size
5.15 MB
Size
0.98 MB
File Count
152
NPM Version
10.5.0
Node Version
18.20.2
Published on
May 22, 2024
Cumulative downloads
Total Downloads
Last Day
-4%
4,766
Compared to previous day
Last Week
-5.8%
127,541
Compared to previous week
Last Month
5.2%
548,411
Compared to previous month
Last Year
13.1%
5,920,093
Compared to previous year
1
1
13
1
ZXing ("zebra crossing") is an open-source, multi-format 1D/2D barcode image processing library implemented in Java, with ports to other languages.
This is a library for enabling you to use with ease the ZXing for JS library on the browser. It includes features like scanning an <img>
element, as well as <video>
, images and videos from URLs and also it helps handling webcam use for scanning directly from a hardware connected camera. It does not offers support to any physical barcode readers or things like that.
See @zxing-js/library for the complete API including decoding classes and use outside of the browser.
See @zxing-js/ngx-scanner for using the library in Angular.
See @zxing-js/text-encoding for special character support in barcodes.
Installation, import into app and usage examples in this section.
Install via yarn, npm, etc:
1yarn add @zxing/browser
1npm i @zxing/browser
Or just import an script tag from your favorite NPM registry connected CDN:
1<!-- loading ZXingBrowser via UNPKG --> 2<script type="text/javascript" src="https://unpkg.com/@zxing/browser@latest"></script>
1<script type="module"> 2 import { BrowserQRCodeReader } from '@zxing/browser'; 3 4 const codeReader = new BrowserQRCodeReader(); 5 6 // do something with codeReader... 7 8</script>
1<script type="module"> 2 import('@zxing/browser').then({ BrowserQRCodeReader } => { 3 4 const codeReader = new BrowserQRCodeReader(); 5 6 // do something with codeReader... 7 8 }); 9</script>
1<script type="text/javascript" src="https://unpkg.com/requirejs"></script> 2<script type="text/javascript"> 3 require(['@zxing/browser'], ZXingBrowser => { 4 5 const codeReader = new ZXingBrowser.BrowserQRCodeReader(); 6 7 // do something with codeReader... 8 9 }); 10</script>
1<script type="text/javascript" src="https://unpkg.com/@zxing/browser@latest"></script> 2<script type="text/javascript"> 3 window.addEventListener('load', () => { 4 5 const codeReader = new ZXingBrowser.BrowserQRCodeReader(); 6 7 // do something with codeReader... 8 9 }); 10</script>
Examples here will assume you already imported ZXingBrowser into your app.
Continuous scan (runs and decodes barcodes until you stop it):
1const codeReader = new BrowserQRCodeReader(); 2 3const videoInputDevices = await ZXingBrowser.BrowserCodeReader.listVideoInputDevices(); 4 5// choose your media device (webcam, frontal camera, back camera, etc.) 6const selectedDeviceId = videoInputDevices[0].deviceId; 7 8console.log(`Started decode from camera with id ${selectedDeviceId}`); 9 10const previewElem = document.querySelector('#test-area-qr-code-webcam > video'); 11 12// you can use the controls to stop() the scan or switchTorch() if available 13const controls = await codeReader.decodeFromVideoDevice(selectedDeviceId, previewElem, (result, error, controls) => { 14 // use the result and error values to choose your actions 15 // you can also use controls API in this scope like the controls 16 // returned from the method. 17}); 18 19// stops scanning after 20 seconds 20setTimeout(() => controls.stop(), 20000);
You can also use decodeFromConstraints
instead of decodeFromVideoDevice
to pass your own constraints for the method choose the device you want directly from your constraints.
Also, decodeOnceFromVideoDevice
is available too so you can await
the method until it detects the first barcode.
1const codeReader = new ZXingBrowser.BrowserQRCodeReader(); 2 3const source = 'https://my-image-or-video/01.png'; 4const resultImage = await codeReader.decodeFromImageUrl(source); 5// or use decodeFromVideoUrl for videos 6const resultVideo = await codeReader.decodeFromVideoUrl(source);
1const codeReader = new ZXingBrowser.BrowserQRCodeReader(); 2 3const sourceElem = document.querySelector('#my-image-id'); 4const resultImage = await codeReader.decodeFromImageElement(sourceElem); 5// or use decodeFromVideoElement for videos 6const resultVideo = await codeReader.decodeFromVideoElement(sourceElem);
There's still other scan methods you can use for decoding barcodes in the browser with BrowserCodeReader
family, all of those and previous listed in here:
decodeFromCanvas
decodeFromImageElement
decodeFromImageUrl
decodeFromConstraints
decodeFromStream
decodeFromVideoDevice
decodeFromVideoElement
decodeFromVideoUrl
decodeOnceFromConstraints
decodeOnceFromStream
decodeOnceFromVideoDevice
decodeOnceFromVideoElement
decodeOnceFromVideoUrl
That's it for now.
BrowserAztecCodeReader
BrowserCodeReader
(abstract, needs to be extend for use)BrowserDatamatrixCodeReader
BrowserMultiFormatOneDReader
BrowserMultiFormatReader
(2D + 1D)BrowserPDF417CodeReader
BrowserQRCodeReader
BrowserCodeReader
optionsYou can also customize some options on the code reader at instantiation time. More docs comming soon.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 4/10 approved changesets -- score normalized to 4
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
23 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More