jsqr vs @zxing/library vs html5-qrcode vs qrcode-reader vs qr-scanner
JavaScript QR Code Libraries Comparison
1 Year
jsqr@zxing/libraryhtml5-qrcodeqrcode-readerqr-scannerSimilar Packages:
What's JavaScript QR Code Libraries?

These libraries provide functionality for reading and generating QR codes in web applications. They utilize various techniques to decode QR codes from images or camera streams, enabling developers to integrate QR code scanning capabilities into their applications. Each library has its unique features, performance characteristics, and use cases, making them suitable for different scenarios in web development.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
jsqr327,1903,803-964 years agoApache-2.0
@zxing/library284,6322,6049.46 MB1706 months agoMIT
html5-qrcode117,3635,3102.63 MB3852 years agoApache-2.0
qrcode-reader69,873279-177 years agoApache-2.0
qr-scanner66,4662,614524 kB113-MIT
Feature Comparison: jsqr vs @zxing/library vs html5-qrcode vs qrcode-reader vs qr-scanner

Performance

  • jsqr:

    jsqr is lightweight and fast, designed specifically for decoding QR codes from image data. Its performance is excellent for static images, but it may not be as optimized for real-time camera scanning compared to other libraries.

  • @zxing/library:

    @zxing/library is known for its high performance and accuracy in decoding QR codes. It employs advanced algorithms that allow for quick processing, making it suitable for applications that require real-time scanning capabilities.

  • html5-qrcode:

    html5-qrcode is optimized for speed and efficiency, particularly in mobile environments. It leverages the device's camera for instant scanning, providing a seamless user experience without noticeable lag.

  • qrcode-reader:

    qrcode-reader offers decent performance for basic QR code decoding tasks. While it may not match the speed of more specialized libraries, it is sufficient for simple applications that do not require real-time processing.

  • qr-scanner:

    qr-scanner is built with performance in mind, utilizing WebAssembly for faster processing. It excels in mobile scenarios, providing quick scanning even in low-light conditions, making it ideal for on-the-go applications.

Ease of Use

  • jsqr:

    jsqr is straightforward to use, focusing on decoding images rather than camera integration. Developers can easily implement it in applications that require image processing without complex configurations.

  • @zxing/library:

    @zxing/library has a steeper learning curve due to its comprehensive feature set and configuration options. However, once set up, it provides extensive capabilities for QR code processing.

  • html5-qrcode:

    html5-qrcode is very user-friendly, with a simple API that allows developers to quickly implement QR code scanning with minimal setup. It is ideal for beginners or projects that need rapid deployment.

  • qrcode-reader:

    qrcode-reader is easy to integrate and use, with a minimalistic API. It is suitable for projects that need basic QR code functionality without extensive features.

  • qr-scanner:

    qr-scanner is designed for ease of use, providing a simple interface for both camera and image scanning. Its documentation is clear, making it accessible for developers of all skill levels.

Camera Support

  • jsqr:

    jsqr does not include camera support; it focuses on decoding QR codes from image data. Developers need to handle camera integration separately if required.

  • @zxing/library:

    @zxing/library does not provide built-in camera support, requiring additional implementation for capturing images from the camera. This may add complexity to the integration process.

  • html5-qrcode:

    html5-qrcode excels in camera support, allowing developers to access the device camera seamlessly. It provides real-time scanning capabilities directly from the camera feed, enhancing user experience.

  • qrcode-reader:

    qrcode-reader does not support camera functionality natively, focusing instead on decoding from static images. Additional work is needed to integrate camera capabilities.

  • qr-scanner:

    qr-scanner offers robust camera support, enabling real-time scanning from the camera feed. It is optimized for mobile devices, making it a great choice for applications that rely on camera input.

Supported Formats

  • jsqr:

    jsqr is specifically designed for QR code decoding, offering high performance and accuracy for this format. It does not support other barcode types, making it a focused solution.

  • @zxing/library:

    @zxing/library supports a wide range of barcode formats beyond just QR codes, making it a versatile choice for applications that may need to handle different types of barcodes.

  • html5-qrcode:

    html5-qrcode primarily focuses on QR codes, providing excellent support for this format. It is specialized for QR code scanning, ensuring high accuracy and performance.

  • qrcode-reader:

    qrcode-reader is focused on QR codes as well, providing basic functionality for decoding this specific format without additional support for other types.

  • qr-scanner:

    qr-scanner is dedicated to QR code scanning and does not support other formats. It is optimized for QR codes, ensuring quick and reliable decoding.

Community and Support

  • jsqr:

    jsqr has a smaller community but is well-documented, allowing developers to understand its usage quickly. It is suitable for projects that require straightforward QR code decoding.

  • @zxing/library:

    @zxing/library has a large community and extensive documentation, providing ample resources for troubleshooting and support. It is widely used in various applications, ensuring a wealth of shared knowledge.

  • html5-qrcode:

    html5-qrcode has a growing community with good documentation, making it easy for developers to find help and examples. Its simplicity contributes to its popularity among new developers.

  • qrcode-reader:

    qrcode-reader has limited community support compared to others, but it is straightforward enough that most developers can implement it without extensive assistance.

  • qr-scanner:

    qr-scanner has a supportive community and decent documentation, helping developers implement the library effectively. Its focus on performance has garnered attention in mobile development circles.

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

    Opt for jsqr if you need a lightweight library focused on QR code decoding from image data. It is particularly useful for applications that require quick processing of static images or canvas elements without additional dependencies.

  • @zxing/library:

    Choose @zxing/library if you need a comprehensive and robust solution for QR code scanning that supports multiple formats and is well-tested across various platforms. It is ideal for applications requiring high accuracy and performance.

  • html5-qrcode:

    Select html5-qrcode for a straightforward implementation that allows for easy integration of QR code scanning directly from the camera. It is user-friendly and suitable for projects that prioritize quick setup and ease of use.

  • qrcode-reader:

    Choose qrcode-reader for a simple and effective solution for decoding QR codes from images. It is best for projects that require basic functionality without the need for extensive features or camera integration.

  • qr-scanner:

    Use qr-scanner if you want a library that offers both camera and image scanning capabilities with a focus on performance. It is designed for mobile-first applications and provides a responsive experience for users.

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.