html5-qrcode, jsqr, qr-scanner, and qrcode-reader are JavaScript libraries designed to decode QR codes within web environments. html5-qrcode is a high-level solution that manages camera permissions and video streams out of the box. jsqr is a low-level engine that requires manual handling of image data, often used when custom video pipelines are needed. qr-scanner is a modern, lightweight library optimized for performance with web worker support. qrcode-reader is a legacy library that primarily handles static image data and is less maintained than modern alternatives.
When integrating QR code scanning into a web application, the choice of library dictates how much control you have over the camera, the video stream, and the decoding process. html5-qrcode, jsqr, qr-scanner, and qrcode-reader represent different points on the spectrum from high-level abstraction to low-level control. Let's examine how they handle core engineering challenges.
html5-qrcode manages the entire media stream lifecycle for you.
// html5-qrcode: High-level camera handling
const html5QrCode = new Html5Qrcode("reader");
html5QrCode.start(
{ facingMode: "environment" },
{ fps: 10, qrbox: 250 },
(decodedText) => console.log(decodedText)
);
jsqr does not handle camera access at all.
navigator.mediaDevices API to get the stream.// jsqr: Manual camera setup
const stream = await navigator.mediaDevices.getUserMedia({ video: { facingMode: "environment" } });
videoElement.srcObject = stream;
videoElement.onplay = () => {
const imageData = ctx.drawImage(videoElement, 0, 0, width, height);
const code = jsQR(imageData.data, width, height);
};
qr-scanner provides a helper class to manage the video element.
// qr-scanner: Semi-automated video handling
const scanner = new QrScanner(videoElement, result => console.log(result));
scanner.start();
qrcode-reader has no built-in camera support.
jsqr, you must manually capture frames from a video stream.// qrcode-reader: Manual camera setup
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
videoElement.srcObject = stream;
videoElement.onplay = () => {
const image = { data: ctx.getImageData(0, 0, width, height) };
qrcodeReader.decode(image);
};
html5-qrcode supports both modes via distinct methods.
// html5-qrcode: File scanning
html5QrCode.scanFile(fileInput.files[0], true)
.then(text => console.log(text));
jsqr works on raw image data arrays.
Uint8ClampedArray.// jsqr: Raw data decoding
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const code = jsQR(imageData.data, imageData.width, imageData.height);
qr-scanner offers a static method for files and a class for streams.
// qr-scanner: Static file scanning
QrScanner.scanImage(fileInput.files[0])
.then(result => console.log(result));
qrcode-reader is designed primarily for static image objects.
// qrcode-reader: Static image decoding
const image = { data: ctx.getImageData(0, 0, w, h) };
qrcodeReader.decode(image);
html5-qrcode runs decoding on the main thread by default.
// html5-qrcode: Configuring scan rate
html5QrCode.start(
{ facingMode: "environment" },
{ fps: 5 }, // Limit frames per second to save CPU
onScanSuccess
);
jsqr runs entirely on the main thread.
// jsqr: Manual worker implementation
// You must write the worker code yourself to use jsqr off-thread
worker.postMessage({ data: imageData.data, width, height });
qr-scanner supports Web Workers out of the box.
// qr-scanner: Enabling Web Worker
const scanner = new QrScanner(
videoElement,
result => console.log(result),
{ highlightScanRegion: true, highlightCodeOutline: true }
);
// Worker path is configured during build or via CDN
qrcode-reader runs on the main thread.
// qrcode-reader: Main thread execution
// No built-in worker support; runs synchronously
qrcodeReader.decode(image);
html5-qrcode renders its own UI overlay.
// html5-qrcode: Using raw API for custom UI
const html5QrCode = new Html5Qrcode("full-screen-region");
// You must build your own video element and overlay if not using default
jsqr provides no UI components.
// jsqr: Custom overlay drawing
if (code) {
ctx.beginPath();
ctx.moveTo(code.location.topLeftCorner.x, code.location.topLeftCorner.y);
ctx.lineTo(code.location.topRightCorner.x, code.location.topRightCorner.y);
ctx.stroke();
}
qr-scanner allows optional highlight rendering.
// qr-scanner: Built-in highlights
const scanner = new QrScanner(video, result => {}, {
highlightScanRegion: true,
highlightCodeOutline: true
});
qrcode-reader provides no UI or drawing helpers.
// qrcode-reader: Manual visualization
qrcodeReader.callback = (error, result) => {
if (!error) {
// Manually draw result.bounds on canvas
}
};
html5-qrcode is actively maintained with frequent updates.
// html5-qrcode: Standard import
import { Html5Qrcode } from "html5-qrcode";
jsqr is stable but sees fewer feature updates.
// jsqr: Standard import
import jsQR from "jsqr";
qr-scanner is modern and actively developed.
// qr-scanner: Standard import
import QrScanner from "qr-scanner";
qrcode-reader is considered legacy with minimal recent activity.
// qrcode-reader: Standard import
import QrcodeReader from "qrcode-reader";
Despite their architectural differences, all four libraries share the same fundamental goal and some common traits.
// All libraries eventually provide the decoded text
// html5-qrcode
onScanSuccess(decodedText);
// jsqr
console.log(code.data);
// qr-scanner
result => console.log(result.data);
// qrcode-reader
callback(error, result) => console.log(result.result);
// All require canvas context for image data
const ctx = canvas.getContext("2d");
// Used by jsqr, qrcode-reader, and manually by others
// html5-qrcode
onScanFailure(error);
// jsqr
if (!code) { /* handle failure */ }
// qr-scanner
.catch(error => console.error(error));
// qrcode-reader
callback(error, result) => if (error) { /* handle */ }
// Installation command is similar for all
npm install html5-qrcode
npm install jsqr
npm install qr-scanner
npm install qrcode-reader
| Feature | html5-qrcode | jsqr | qr-scanner | qrcode-reader |
|---|---|---|---|---|
| Level | High-level | Low-level | Mid-level | Low-level (Legacy) |
| Camera Handling | β Built-in | β Manual | β Helper Class | β Manual |
| Web Workers | β Main Thread | β Manual | β Built-in | β Main Thread |
| UI Components | β Default UI | β None | β οΈ Optional Highlights | β None |
| Maintenance | β Active | β οΈ Stable | β Active | β οΈ Legacy |
html5-qrcode is the rapid deployment choice π β perfect for internal tools, prototypes, or when you need a working scanner in minutes without worrying about camera permissions.
jsqr is the custom engine choice π οΈ β best when you are building a specialized video pipeline or need to integrate scanning into a complex canvas manipulation workflow.
qr-scanner is the modern balanced choice βοΈ β ideal for production consumer apps where performance matters and you want a lightweight solution with worker support.
qrcode-reader is the legacy choice π°οΈ β generally avoid for new work, but useful if you are maintaining older systems that depend on its specific API.
Final Thought: For most modern frontend applications, qr-scanner offers the best balance of performance and ease of use. However, if you need a full UI kit immediately, html5-qrcode saves significant development time.
Choose html5-qrcode if you need a complete, plug-and-play solution that handles camera access, UI rendering, and scanning logic with minimal setup. It is ideal for rapid prototyping or applications where developer speed is more critical than bundle size optimization.
Choose jsqr if you require full control over the image processing pipeline, such as when integrating with custom video elements or canvas manipulations. It is best suited for advanced use cases where you need to decode raw image data without built-in camera management.
Choose qr-scanner if performance and bundle size are top priorities, and you want a modern library with web worker support to avoid blocking the main thread. It is suitable for production apps that need a balance between ease of use and efficiency.
Avoid qrcode-reader for new projects as it is largely considered legacy software with infrequent updates. Only consider it if you are maintaining an older codebase that already depends on its specific API for static image decoding.
Use this lightweight library to easily / quickly integrate QR code, bar code, and other common code scanning capabilities to your web application.
π² Support scanning different types of bar codes and QR codes.
π₯ Supports different platforms be it Android, IOS, MacOs, Windows or Linux
π Supports different browsers like Chrome, Firefox, Safari, Edge, Opera ...
π· Supports scanning with camera as well as local files
β‘οΈ Comes with an end to end library with UI as well as a low level library to build your own UI with.
π¦ Supports customisations like flash/torch support, zooming etc.
Supports two kinds of APIs
Html5QrcodeScanner β End-to-end scanner with UI, integrate with less than ten lines of code.
Html5Qrcode β Powerful set of APIs you can use to build your UI without worrying about camera setup, handling permissions, reading codes, etc.
Support for scanning local files on the device is a new addition and helpful for the web browser which does not support inline web-camera access in smartphones. Note: This doesn't upload files to any server β everything is done locally.
| Demo at scanapp.org | Demo at qrcode.minhazav.dev - Scanning different types of codes |
Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See list of sponsered feature requests here.
The documentation for this project has been moved to scanapp.org/html5-qrcode-docs.
We are working continuously on adding support for more and more platforms. If you find a platform or a browser where the library is not working, please feel free to file an issue. Check the demo link to test it out.
Legends
Means full support β inline webcam and file based
Means partial support β only file based, webcam in progress![]() Firefox | ![]() Chrome | ![]() Safari | ![]() Opera | ![]() Edge |
|---|---|---|---|---|
![]() | ![]() | ![]() | ![]() | ![]() |
![]() Chrome | ![]() Firefox | ![]() Edge | ![]() Opera | ![]() Opera Mini | UC |
|---|---|---|---|---|---|
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
![]() Safari | ![]() Chrome | ![]() Firefox | ![]() Edge |
|---|---|---|---|
![]() | * | * | ![]() |
* Supported for IOS versions >= 15.1
Before version 15.1, Webkit for IOS is used by Chrome, Firefox, and other browsers in IOS and they do not have webcam permissions yet. There is an ongoing issue on fixing the support for iOS - issue/14
The library can be easily used with several other frameworks, I have been adding examples for a few of them and would continue to add more.
![]() | ![]() | ![]() | ![]() | |
|---|---|---|---|---|
| Html5 | VueJs | ElectronJs | React | Lit |
Code scanning is dependent on Zxing-js library. We will be working on top of it to add support for more types of code scanning. If you feel a certain type of code would be helpful to have, please file a feature request.
| Code | Example |
|---|---|
| QR Code | ![]() |
| AZTEC | ![]() |
| CODE_39 | ![]() |
| CODE_93 | ![]() |
| CODE_128 | ![]() |
| ITF | ![]() |
| EAN_13 | ![]() |
| EAN_8 | ![]() |
| PDF_417 | ![]() |
| UPC_A | ![]() |
| UPC_E | ![]() |
| DATA_MATRIX | ![]() |
| MAXICODE* | ![]() |
| RSS_14* | ![]() |
| RSS_EXPANDED* | ![]() |
*Formats are not supported by our experimental integration with native BarcodeDetector API integration (Read more).
See an end to end scanner experience at scanapp.org.
This is a cross-platform JavaScript library to integrate QR code, bar codes & a few other types of code scanning capabilities to your applications running on HTML5 compatible browser.
Supports:
Find detailed guidelines on how to use this library on scanapp.org/html5-qrcode-docs.

Scan this image or visit blog.minhazav.dev/research/html5-qrcode.html
Check these articles on how to use this library:

Figure: Screenshot from Google Chrome running on MacBook Pro
Find the full API documentation at scanapp.org/html5-qrcode-docs/docs/apis.
configuration in start() methodConfiguration object that can be used to configure both the scanning behavior and the user interface (UI). Most of the fields have default properties that will be used unless a different value is provided. If you do not want to override anything, you can just pass in an empty object {}.
fps β Integer, Example = 10A.K.A frame per second, the default value for this is 2, but it can be increased to get faster scanning. Increasing too high value could affect performance. Value >1000 will simply fail.
qrbox β QrDimensions or QrDimensionFunction (Optional), Example = { width: 250, height: 250 }Use this property to limit the region of the viewfinder you want to use for scanning. The rest of the viewfinder would be shaded. For example, by passing config { qrbox : { width: 250, height: 250 } }, the screen will look like:
This can be used to set a rectangular scanning area with config like:
let config = { qrbox : { width: 400, height: 150 } }
This config also accepts a function of type
/**
* A function that takes in the width and height of the video stream
* and returns QrDimensions.
*
* Viewfinder refers to the video showing camera stream.
*/
type QrDimensionFunction =
(viewfinderWidth: number, viewfinderHeight: number) => QrDimensions;
This allows you to set dynamic QR box dimensions based on the video dimensions. See this blog article for example: Setting dynamic QR box size in Html5-qrcode - ScanApp blog
This might be desirable for bar code scanning.
If this value is not set, no shaded QR box will be rendered and the scanner will scan the entire area of video stream.
aspectRatio β Float, Example 1.777778 for 16:9 aspect ratioUse this property to render the video feed in a certain aspect ratio. Passing a nonstandard aspect ratio like 100000:1 could lead to the video feed not even showing up. Ideal values can be:
| Value | Aspect Ratio | Use Case |
|---|---|---|
| 1.333334 | 4:3 | Standard camera aspect ratio |
| 1.777778 | 16:9 | Full screen, cinematic |
| 1.0 | 1:1 | Square view |
If you do not pass any value, the whole viewfinder would be used for scanning.
Note: this value has to be smaller than the width and height of the QR code HTML element.
disableFlip β Boolean (Optional), default = falseBy default, the scanner can scan for horizontally flipped QR Codes. This also enables scanning QR code using the front camera on mobile devices which are sometimes mirrored. This is false by default and I recommend changing this only if:
Here's an example of a normal and mirrored QR Code
| Normal QR Code | Mirrored QR Code |
|---|---|
![]() | ![]() |
rememberLastUsedCamera β Boolean (Optional), default = trueIf true the last camera used by the user and weather or not permission was granted would be remembered in the local storage. If the user has previously granted permissions β the request permission option in the UI will be skipped and the last selected camera would be launched automatically for scanning.
If true the library shall remember if the camera permissions were previously
granted and what camera was last used. If the permissions is already granted for
"camera", QR code scanning will automatically * start for previously used camera.
supportedScanTypes - Array<Html5QrcodeScanType> | []This is only supported for
Html5QrcodeScanner.
Default = [Html5QrcodeScanType.SCAN_TYPE_CAMERA, Html5QrcodeScanType.SCAN_TYPE_FILE]
This field can be used to:
Camera or File based scan.How to use:
function onScanSuccess(decodedText, decodedResult) {
// handle the scanned code as you like, for example:
console.log(`Code matched = ${decodedText}`, decodedResult);
}
let config = {
fps: 10,
qrbox: {width: 100, height: 100},
rememberLastUsedCamera: true,
// Only support camera scan type.
supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_CAMERA]
};
let html5QrcodeScanner = new Html5QrcodeScanner(
"reader", config, /* verbose= */ false);
html5QrcodeScanner.render(onScanSuccess);
For file based scan only choose:
supportedScanTypes: [Html5QrcodeScanType.SCAN_TYPE_FILE]
For supporting both as it is today, you can ignore this field or set as:
supportedScanTypes: [
Html5QrcodeScanType.SCAN_TYPE_CAMERA,
Html5QrcodeScanType.SCAN_TYPE_FILE]
To set the file based scan as defult change the order:
supportedScanTypes: [
Html5QrcodeScanType.SCAN_TYPE_FILE,
Html5QrcodeScanType.SCAN_TYPE_CAMERA]
showTorchButtonIfSupported - boolean | undefinedThis is only supported for
Html5QrcodeScanner.
If true the rendered UI will have button to turn flash on or off based on device + browser support. The value is false by default.
By default, both camera stream and image files are scanned against all the
supported code formats. Both Html5QrcodeScanner and Html5Qrcode classes can
be configured to only support a subset of supported formats. Supported formats
are defined in
enum Html5QrcodeSupportedFormats.
enum Html5QrcodeSupportedFormats {
QR_CODE = 0,
AZTEC,
CODABAR,
CODE_39,
CODE_93,
CODE_128,
DATA_MATRIX,
MAXICODE,
ITF,
EAN_13,
EAN_8,
PDF_417,
RSS_14,
RSS_EXPANDED,
UPC_A,
UPC_E,
UPC_EAN_EXTENSION,
}
I recommend using this only if you need to explicitly omit support for certain formats or want to reduce the number of scans done per second for performance reasons.
Html5Qrcodeconst html5QrCode = new Html5Qrcode(
"reader", { formatsToSupport: [ Html5QrcodeSupportedFormats.QR_CODE ] });
const qrCodeSuccessCallback = (decodedText, decodedResult) => {
/* handle success */
};
const config = { fps: 10, qrbox: { width: 250, height: 250 } };
// If you want to prefer front camera
html5QrCode.start({ facingMode: "user" }, config, qrCodeSuccessCallback);
Html5QrcodeScannerfunction onScanSuccess(decodedText, decodedResult) {
// Handle the scanned code as you like, for example:
console.log(`Code matched = ${decodedText}`, decodedResult);
}
const formatsToSupport = [
Html5QrcodeSupportedFormats.QR_CODE,
Html5QrcodeSupportedFormats.UPC_A,
Html5QrcodeSupportedFormats.UPC_E,
Html5QrcodeSupportedFormats.UPC_EAN_EXTENSION,
];
const html5QrcodeScanner = new Html5QrcodeScanner(
"reader",
{
fps: 10,
qrbox: { width: 250, height: 250 },
formatsToSupport: formatsToSupport
},
/* verbose= */ false);
html5QrcodeScanner.render(onScanSuccess);
The library now supports some experimental features which are supported in the library but not recommended for production usage either due to limited testing done or limited compatibility for underlying APIs used. Read more about it here. Some experimental features include:
Code changes should only be made to /src only.
Run npm install to install all dependencies.
Run npm run-script build to build JavaScript output. The output JavaScript distribution is built to /dist/html5-qrcode.min.js. If you are developing on Windows OS, run npm run-script build-windows.
Testing
npm testSend a pull request
./src. Do not change ./dist manually.@all-contributors please add @mebjas for this new feature or tests
You can contribute to the project in several ways:
This project would not be possible without all of our fantastic contributors and sponsors. If you'd like to support the maintenance and upkeep of this project you can donate via GitHub Sponsors.
Sponsor the project for priortising feature requests / bugs relevant to you. (Depends on scope of ask and bandwidth of the contributors).
Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See list of sponsered feature requests here.
Also, huge thanks to following organizations for non monitery sponsorships
The decoder used for the QR code reading is from Zxing-js https://github.com/zxing-js/library