jsqr vs qrcode-reader vs html5-qrcode vs qr-scanner
JavaScript QR Code Libraries Comparison
1 Year
jsqrqrcode-readerhtml5-qrcodeqr-scannerSimilar Packages:
What's JavaScript QR Code Libraries?

These libraries are designed to facilitate the reading and generation of QR codes in web applications. They provide developers with tools to easily integrate QR code scanning functionality into their applications, allowing users to interact with QR codes for various purposes such as authentication, payment processing, and information retrieval. Each library has its unique features, performance characteristics, and use cases, making them suitable for different project requirements and developer preferences.

NPM Package Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
jsqr171,9693,765-964 years agoApache-2.0
qrcode-reader60,657278-177 years agoApache-2.0
html5-qrcode59,1975,1902.63 MB3752 years agoApache-2.0
qr-scanner26,1602,560524 kB113-MIT
Feature Comparison: jsqr vs qrcode-reader vs html5-qrcode vs qr-scanner

Scanning Capability

  • jsqr:

    jsqr focuses solely on scanning QR codes from image data. It is optimized for performance and can decode QR codes quickly, making it suitable for applications that require fast processing without additional features.

  • qrcode-reader:

    qrcode-reader can read QR codes from images and video streams, providing flexibility for various use cases. It includes robust error handling and supports multiple image formats, ensuring reliable QR code reading.

  • html5-qrcode:

    html5-qrcode offers both scanning and generating capabilities, allowing developers to implement QR code functionality seamlessly. It supports real-time scanning using the device's camera and can also generate QR codes from text or URLs.

  • qr-scanner:

    qr-scanner provides real-time scanning functionality directly from the camera feed, making it ideal for mobile applications. It automatically adjusts to different lighting conditions and camera resolutions to enhance scanning accuracy.

Ease of Use

  • jsqr:

    jsqr has a minimalistic API that is easy to use for developers familiar with JavaScript. It requires only a few lines of code to set up and start scanning, making it a good choice for quick implementations.

  • qrcode-reader:

    qrcode-reader provides a comprehensive API that may require more initial setup compared to others, but it offers detailed documentation and examples to guide developers through the integration process.

  • html5-qrcode:

    html5-qrcode is designed with simplicity in mind, featuring a straightforward API that allows developers to quickly integrate QR code functionality into their applications. Its documentation is user-friendly, making it accessible for developers of all skill levels.

  • qr-scanner:

    qr-scanner offers a simple setup process and clear documentation, making it easy for developers to implement real-time scanning in their applications. Its focus on mobile usability enhances the user experience.

Performance

  • jsqr:

    jsqr is highly efficient and lightweight, designed specifically for fast QR code scanning. Its performance is particularly notable when processing large images or when high-speed scanning is necessary.

  • qrcode-reader:

    qrcode-reader provides reliable performance but may not be as fast as jsqr or qr-scanner in real-time scenarios. It is more suited for applications where reading from static images is the primary use case.

  • html5-qrcode:

    html5-qrcode is optimized for performance, allowing for quick scanning and generation of QR codes. It balances functionality and speed, making it suitable for applications that require both features without compromising on performance.

  • qr-scanner:

    qr-scanner excels in real-time performance, leveraging the device's camera for instant scanning. It is optimized for mobile devices, ensuring smooth user experiences even in varying conditions.

Compatibility

  • jsqr:

    jsqr is a pure JavaScript library that can run in any environment that supports JavaScript, making it highly compatible with different frameworks and applications.

  • qrcode-reader:

    qrcode-reader supports multiple image formats and can be integrated into various web applications, making it versatile for different development environments.

  • html5-qrcode:

    html5-qrcode is compatible with modern web browsers and supports various devices, ensuring a wide range of usability across platforms. It is designed to work seamlessly on both desktop and mobile environments.

  • qr-scanner:

    qr-scanner is designed for mobile-first applications and works well on both Android and iOS devices. Its compatibility with various camera types enhances its usability in real-world scenarios.

Community and Support

  • jsqr:

    jsqr is a well-maintained library with an active community. It has comprehensive documentation and examples, making it easier for developers to find help and resources.

  • qrcode-reader:

    qrcode-reader has a dedicated user base and provides extensive documentation. However, its community may not be as large as some of the other libraries, which could affect the availability of third-party resources.

  • html5-qrcode:

    html5-qrcode has a growing community and provides good support through documentation and GitHub issues. Its popularity is increasing, which may lead to more community-contributed resources in the future.

  • qr-scanner:

    qr-scanner has a supportive community and offers solid documentation. Developers can find various tutorials and examples online to assist with implementation.

How to Choose: jsqr vs qrcode-reader vs html5-qrcode vs qr-scanner
  • jsqr:

    Select jsqr if you require a lightweight and efficient library specifically for QR code scanning. It is designed for performance and can decode QR codes directly from image data, making it ideal for applications that need fast scanning capabilities without additional features.

  • qrcode-reader:

    Choose qrcode-reader if you need a comprehensive solution for reading QR codes from images or video streams. It supports various image formats and provides detailed error handling, making it suitable for applications that require robust QR code reading capabilities.

  • html5-qrcode:

    Choose html5-qrcode if you need a library that supports both scanning and generating QR codes with a focus on simplicity and ease of use. It offers a straightforward API and is suitable for applications that require quick integration without complex setup.

  • qr-scanner:

    Opt for qr-scanner if you are looking for a library that provides real-time scanning capabilities using the device's camera. It is particularly useful for mobile applications where instant scanning is essential, and it includes features for handling different camera resolutions and lighting conditions.

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.