jsqr vs html5-qrcode vs qr-scanner vs qrcode-reader vs @zxing/library
Client-Side QR Code Scanning Libraries for Web Applications
jsqrhtml5-qrcodeqr-scannerqrcode-reader@zxing/librarySimilar Packages:

Client-Side QR Code Scanning Libraries for Web Applications

@zxing/library, html5-qrcode, jsqr, qr-scanner, and qrcode-reader are JavaScript libraries that enable QR code detection and decoding directly in the browser using device cameras or image inputs. These packages vary significantly in scope, API design, performance characteristics, and maintenance status. While some provide full-featured camera integration with real-time scanning, others focus solely on decoding raw pixel data from images or video frames, requiring developers to handle media setup manually.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
jsqr1,932,5614,033-975 years agoApache-2.0
html5-qrcode1,088,5546,2282.63 MB4453 years agoApache-2.0
qr-scanner254,0252,890524 kB119-MIT
qrcode-reader81,763281-179 years agoApache-2.0
@zxing/library02,93311.9 MB1795 months agoApache-2.0

Client-Side QR Code Scanning: A Practical Comparison of JavaScript Libraries

When you need to scan QR codes in a web app, you have several libraries to choose from β€” but they differ dramatically in what they do, how much work they save you, and whether they’re still maintained. Let’s cut through the noise and compare the real engineering trade-offs.

🚫 Deprecation Warning: Avoid qrcode-reader

First, the easy decision: qrcode-reader is deprecated. Its npm page states it’s no longer maintained, and the GitHub repo hasn’t seen updates in years. Don’t use it in new projects. We’ll include it in comparisons only for completeness, but treat it as obsolete.

πŸ“Έ Camera Integration vs Pure Decoding

The biggest split among these libraries is whether they handle the entire scanning flow (camera access, UI, real-time decoding) or just the decoding step (turning pixel data into text).

Full-Stack Scanners: html5-qrcode and qr-scanner

These packages manage everything:

  • Request camera permissions
  • Render a video feed
  • Continuously analyze frames
  • Fire callbacks when a QR code is found

html5-qrcode example:

import { Html5Qrcode } from "html5-qrcode";

const html5QrCode = new Html5Qrcode("reader");
html5QrCode.start(
  { facingMode: "environment" },
  { fps: 10, qrbox: { width: 250, height: 250 } },
  (decodedText) => console.log("Found:", decodedText),
  (errorMessage) => console.log("Error:", errorMessage)
);

qr-scanner example:

import QrScanner from "qr-scanner";
import QrFrame from "qr-scanner/qr-scanner.min.js";

const video = document.getElementById("video");
const scanner = new QrScanner(video, result => console.log(result));
scanner.start();

Note: qr-scanner requires you to include its worker script separately for optimal performance.

Decoder-Only Libraries: @zxing/library and jsqr

These expect you to provide raw image data (e.g., from a <canvas> or <video> frame). You handle camera setup, frame capture, and retry logic.

jsqr example:

import jsQR from "jsqr";

const canvas = document.createElement("canvas");
const ctx = canvas.getContext("2d");
// Assume video is already streaming
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);

const code = jsQR(imageData.data, imageData.width, imageData.height);
if (code) console.log("Found:", code.data);

@zxing/library example:

import { BrowserMultiFormatReader } from "@zxing/library";

const codeReader = new BrowserMultiFormatReader();
const video = document.querySelector("video");

// Start decoding from video stream
const controls = await codeReader.decodeFromVideoDevice(
  null,
  video,
  (result, error, controls) => {
    if (result) console.log("Found:", result.getText());
  }
);

@zxing/library does offer high-level camera helpers (decodeFromVideoDevice), but they’re less polished than html5-qrcode’s API.

βš™οΈ Performance Considerations

  • jsqr runs entirely in the main thread. For smooth UI, you must throttle frame analysis (e.g., using requestAnimationFrame with skips).
  • qr-scanner uses a Web Worker by default to avoid blocking the UI β€” a big plus for responsive apps.
  • @zxing/library can be heavy because it supports many barcode formats; QR-only decoding is possible but not the default.
  • html5-qrcode runs decoding on the main thread but lets you limit FPS to reduce load.

πŸ”§ Customization and Control

Need to tweak the scanning region, add overlays, or handle multiple concurrent scans?

  • jsqr gives maximum control β€” you decide exactly which pixels to analyze and when.
  • qr-scanner allows customizing the scan region and includes a built-in highlight box.
  • html5-qrcode lets you configure the scan area (qrbox) but offers less visual customization.
  • @zxing/library requires manual DOM manipulation for overlays but supports advanced decoding hints.

πŸ“± Mobile and Permission Handling

All camera-enabled libraries must handle getUserMedia() permissions, but their approaches differ:

  • html5-qrcode includes built-in error messages for common issues (e.g., camera not found).
  • qr-scanner throws clear errors but leaves UI feedback to you.
  • @zxing/library propagates raw DOMExceptions β€” you’ll need to map them to user-friendly messages.

πŸ§ͺ File and Image Support

What if you want to scan from an uploaded image, not a camera?

html5-qrcode:

Html5Qrcode.scanFile(file).then(text => console.log(text));

qr-scanner:

QrScanner.scanImage(fileOrUrl).then(result => console.log(result));

jsqr and @zxing/library require you to draw the image to a canvas first, then extract pixel data β€” more code, but more flexible.

πŸ› οΈ Error Handling Patterns

  • html5-qrcode uses separate success/error callbacks.
  • qr-scanner returns promises that reject on errors.
  • jsqr returns null on failure β€” no exceptions thrown.
  • @zxing/library throws errors during decoding, which you must catch in your callback.

πŸ“‹ Summary Table

LibraryCamera Built-in?Worker Support?File Scanning?Multi-Format?Actively Maintained?
@zxing/libraryPartial❌Manualβœ…βœ…
html5-qrcodeβœ…βŒβœ…QR onlyβœ…
jsqr❌❌ManualQR onlyβœ…
qr-scannerβœ…βœ…βœ…QR onlyβœ…
qrcode-reader❌❌ManualQR only❌ (Deprecated)

πŸ’‘ When to Use Which

  • Building a simple QR scanner fast? β†’ html5-qrcode. It’s the quickest path to a working demo.
  • Need smooth performance on mobile? β†’ qr-scanner with its worker-based decoding.
  • Building a custom AR or multi-code experience? β†’ jsqr for pixel-level control.
  • Scanning barcodes and QR codes in inventory apps? β†’ @zxing/library.
  • Starting a new project? β†’ Never qrcode-reader.

Choose based on whether you value convenience (html5-qrcode, qr-scanner) or control (jsqr, @zxing/library). And always check the official docs β€” APIs evolve, and assumptions can break.

How to Choose: jsqr vs html5-qrcode vs qr-scanner vs qrcode-reader vs @zxing/library

  • jsqr:

    Choose jsqr if you're building a custom scanning pipeline and only need a lightweight, dependency-free decoder for static images or pre-captured video frames. It gives you complete control over the media input and processing loop but requires you to implement camera access, frame extraction, and scanning logic yourself. Perfect for performance-critical or highly customized scanning scenarios.

  • html5-qrcode:

    Choose html5-qrcode if you want a simple, all-in-one solution for real-time QR scanning from a webcam with minimal setup. It handles camera enumeration, permission requests, UI rendering, and decoding out of the box, making it ideal for quick integrations where developer experience and ease of use are prioritized over fine-grained control.

  • qr-scanner:

    Choose qr-scanner if you need a balance between ease of use and performance, with built-in camera support and optional worker-based decoding for better responsiveness. It offers a clean API for both file and camera scanning, includes a highlight overlay for detected codes, and allows disabling worker usage if needed. A solid middle-ground choice for most web apps.

  • qrcode-reader:

    Do not choose qrcode-reader for new projects β€” it is officially deprecated according to its npm page and GitHub repository. The package has not been updated in years and lacks modern features like camera integration or performance optimizations. Use one of the actively maintained alternatives instead.

  • @zxing/library:

    Choose @zxing/library if you need a mature, multi-format barcode/QR scanning solution that supports not just QR codes but also many 1D and 2D barcode formats. It provides both low-level decoding APIs and higher-level continuous scanning capabilities, though it requires more manual setup for camera handling compared to turnkey solutions. Best suited for applications requiring broad symbology support beyond QR codes.

README for jsqr

jsQR

Build Status

A pure javascript QR code reading library. This library takes in raw images and will locate, extract and parse any QR code found within.

Demo

Installation

NPM

Available on npm. Can be used in a Node.js program or with a module bundler such as Webpack or Browserify.

npm install jsqr --save
// ES6 import
import jsQR from "jsqr";

// CommonJS require
const jsQR = require("jsqr");

jsQR(...);

Browser

Alternatively for frontend use jsQR.js can be included with a script tag

<script src="jsQR.js"></script>
<script>
  jsQR(...);
</script>

A note on webcams

jsQR is designed to be a completely standalone library for scanning QR codes. By design it does not include any platform specific code. This allows it to just as easily scan a frontend webcam stream, a user uploaded image, or be used as part of a backend Node.js process.

If you want to use jsQR to scan a webcam stream you'll need to extract the ImageData from the video stream. This can then be passed to jsQR. The jsQR demo contains a barebones implementation of webcam scanning that can be used as a starting point and customized for your needs. For more advanced questions you can refer to the getUserMedia docs or the fairly comprehensive webRTC sample code, both of which are great resources for consuming a webcam stream.

Usage

jsQR exports a method that takes in 3 arguments representing the image data you wish to decode. Additionally can take an options object to further configure scanning behavior.

const code = jsQR(imageData, width, height, options?);

if (code) {
  console.log("Found QR code", code);
}

Arguments

  • imageData - An Uint8ClampedArray of RGBA pixel values in the form [r0, g0, b0, a0, r1, g1, b1, a1, ...]. As such the length of this array should be 4 * width * height. This data is in the same form as the ImageData interface, and it's also commonly returned by node modules for reading images.
  • width - The width of the image you wish to decode.
  • height - The height of the image you wish to decode.
  • options (optional) - Additional options.
    • inversionAttempts - (attemptBoth (default), dontInvert, onlyInvert, or invertFirst) - Should jsQR attempt to invert the image to find QR codes with white modules on black backgrounds instead of the black modules on white background. This option defaults to attemptBoth for backwards compatibility but causes a ~50% performance hit, and will probably be default to dontInvert in future versions.

Return value

If a QR is able to be decoded the library will return an object with the following keys.

  • binaryData - Uint8ClampedArray - The raw bytes of the QR code.
  • data - The string version of the QR code data.
  • chunks - The QR chunks.
  • version - The QR version.
  • location - An object with keys describing key points of the QR code. Each key is a point of the form {x: number, y: number}. Has points for the following locations.
    • Corners - topRightCorner/topLeftCorner/bottomRightCorner/bottomLeftCorner;
    • Finder patterns - topRightFinderPattern/topLeftFinderPattern/bottomLeftFinderPattern
    • May also have a point for the bottomRightAlignmentPattern assuming one exists and can be located.

Because the library is written in typescript you can also view the type definitions to understand the API.

Contributing

jsQR is written using typescript. You can view the development source in the src directory.

Tests can be run with

npm test

Besides unit tests the test suite contains several hundred images that can be found in the /tests/end-to-end/ folder.

Not all the images can be read. In general changes should hope to increase the number of images that read. However due to the nature of computer vision some changes may cause images that pass to start to fail and visa versa. To update the expected outcomes run npm run-script generate-test-data. These outcomes can be evaluated in the context of a PR to determine if a change improves or harms the overall ability of the library to read QR codes. A summary of which are passing and failing can be found at /tests/end-to-end/report.json

After testing any changes, you can compile the production version by running

npm run-script build

Pull requests are welcome! Please create seperate branches for seperate features/patches.