html5-qrcode vs qr-scanner vs qrcode-reader vs qrious
QR Code Scanning and Generation in Web Applications
html5-qrcodeqr-scannerqrcode-readerqriousSimilar Packages:

QR Code Scanning and Generation in Web Applications

html5-qrcode, qr-scanner, qrcode-reader, and qrious are JavaScript libraries used for handling QR codes in web environments, but they serve different primary purposes. html5-qrcode and qr-scanner focus on scanning QR codes using the device camera within the browser. qrcode-reader is an older library often used for decoding QR codes from images, primarily in Node.js or legacy browser contexts. qrious is dedicated to generating QR codes on HTML5 Canvas elements. Understanding the distinction between scanning (decoding) and generation (encoding) is critical when selecting the right tool for your architecture.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
html5-qrcode06,1302.63 MB4353 years agoApache-2.0
qr-scanner02,866524 kB118-MIT
qrcode-reader0283-179 years agoApache-2.0
qrious01,625-439 years agoGPL-3.0

QR Code Scanning and Generation: Architecture and API Comparison

When integrating QR code functionality into a web application, architects must distinguish between two distinct operations: scanning (decoding images or camera streams) and generation (encoding data into visual patterns). The packages html5-qrcode, qr-scanner, qrcode-reader, and qrious address these needs differently. Some focus on live camera scanning, others on static image decoding, and one is dedicated solely to generation. Let's analyze how they handle these core tasks.

πŸ“· Live Camera Scanning: Built-In UI vs. Headless Control

Handling live camera feeds in the browser requires managing permissions, video streams, and frame analysis. The approach varies significantly between html5-qrcode and qr-scanner.

html5-qrcode provides a high-level abstraction with a pre-built UI.

  • It handles camera permissions and video element creation automatically.
  • You configure it with a container ID and callback functions.
// html5-qrcode: Integrated UI approach
const html5QrCode = new Html5Qrcode("reader");

const config = { fps: 10, qrbox: { width: 250, height: 250 } };

html5QrCode.start(
  { facingMode: "environment" },
  config,
  (decodedText) => console.log(decodedText),
  (errorMessage) => console.error(errorMessage)
);

qr-scanner is a headless library that expects you to manage the video element.

  • It focuses purely on the decoding logic for performance.
  • You must pass a video element or stream to the scanner instance.
// qr-scanner: Headless control approach
import QrScanner from 'qr-scanner';

const video = document.getElementById('video');
const qrScanner = new QrScanner(video, result => console.log(result));

qrScanner.start();
// You are responsible for attaching the stream to the video element

qrcode-reader does not support live camera scanning out of the box.

  • It is designed to decode data from image objects or buffers.
  • Using it for live video requires manual frame capture and conversion to canvas/image data.
// qrcode-reader: Static image decoding only
const QrCode = require('qrcode-reader');
const qr = new QrCode();

// Requires manual extraction of image data from canvas/video
qr.callback = (err, value) => console.log(value.result);
qr.decode(imageData); 

qrious does not support scanning at all.

  • It is strictly a generation library.
  • Attempting to use it for scanning will result in errors as no decoding methods exist.
// qrious: No scanning capability
// This package cannot be used for scanning
const qr = new QRious({
  element: document.getElementById('canvas'),
  value: 'https://example.com'
});

πŸ–ΌοΈ Generation: Canvas Rendering vs. Data Encoding

Generating QR codes is often needed for sharing content or payment links. qrious and html5-qrcode offer client-side generation, while others focus on decoding.

qrious specializes in Canvas-based generation with customization.

  • You can set colors, sizes, and padding directly in the constructor.
  • It renders immediately to a DOM canvas element.
// qrious: Customizable generation
const qr = new QRious({
  element: document.getElementById('qr-canvas'),
  value: 'https://example.com',
  size: 200,
  foreground: '#000000',
  background: '#ffffff'
});

// Export as data URL
const url = qr.toDataURL();

html5-qrcode includes a generation utility (Html5QrcodeGenerator).

  • It creates a QR code and appends it to a specified container.
  • Less customization compared to qrious, but convenient if you already use the library for scanning.
// html5-qrcode: Basic generation
const html5QrCode = new Html5Qrcode("reader");

html5QrCode.generateQRCode(
  "https://example.com",
  {
    width: 256,
    margin: 1,
  },
  (imageUrl) => console.log("Image URL:", imageUrl)
);

qr-scanner does not support generation.

  • It is strictly a decoding library.
  • You would need a separate package like qrious or qrcode for creation.
// qr-scanner: No generation capability
// Cannot generate QR codes with this library

qrcode-reader does not support generation.

  • It is strictly a decoding library.
  • Like qr-scanner, it requires a companion library for encoding data.
// qrcode-reader: No generation capability
// Cannot generate QR codes with this library

βš™οΈ Configuration and Extensibility

Architects need to know how much control they have over the scanning process, such as frame rates or specific format support.

html5-qrcode allows configuration via a config object.

  • You can adjust frames per second and the scanning box size.
  • It supports multiple barcode formats beyond just QR codes.
// html5-qrcode: Configurable scanning
const config = { 
  fps: 10, 
  qrbox: { width: 250, height: 250 },
  aspectRatio: 1.0 
};

html5QrCode.start({ facingMode: "environment" }, config, onScanSuccess);

qr-scanner offers methods to toggle the camera and check support.

  • It provides a promise-based API for listing cameras.
  • More granular control for switching between front and back cameras.
// qr-scanner: Camera management
QrScanner.listCameras(true).then(cameras => 
  cameras.forEach(camera => console.log(camera.label))
);

qrScanner.setInversionMode('both'); // Support inverted codes

qrcode-reader relies on callback-based configuration.

  • It is less modern and lacks promise-based APIs.
  • Configuration is minimal, focusing mostly on the decode callback.
// qrcode-reader: Callback based
qr.callback = (err, value) => {
  if (err) console.error(err);
  else console.log(value.result);
};

qrious uses a declarative object for configuration.

  • All visual aspects are defined at initialization or via setters.
  • It supports MIME type export options (PNG, JPEG, etc.).
// qrious: Visual configuration
qr.set({
  value: 'New Value',
  size: 300,
  mime: 'image/png'
});

πŸ—‘οΈ Maintenance and Modern Standards

The age of a library impacts its compatibility with modern build tools and browser APIs.

html5-qrcode is actively maintained and modern.

  • It uses modern JavaScript and supports TypeScript definitions.
  • Regularly updated to handle new browser permission changes.

qr-scanner is lightweight and modern.

  • Written in TypeScript with strong type safety.
  • Designed for modern bundlers like Webpack and Vite without polyfills.

qrcode-reader is considered legacy.

  • It has not seen significant updates in years.
  • Lacks modern TypeScript support and may require shims for newer environments.

qrious is stable but mature.

  • It is a reliable choice for generation but sees fewer feature updates.
  • Works well in modern environments despite being older.

πŸ“Š Summary: Capabilities Matrix

Featurehtml5-qrcodeqr-scannerqrcode-readerqrious
Live Scanningβœ… (With UI)βœ… (Headless)❌ (Static Only)❌
Generationβœ… (Basic)βŒβŒβœ… (Advanced)
UI Componentsβœ… Built-in❌ Custom❌❌
TypeScriptβœ…βœ…βŒβš οΈ Partial
StatusActiveActiveLegacyStable

πŸ’‘ The Big Picture

html5-qrcode is the pragmatic choice for full-featured apps.

  • Use it when you need both scanning and generation with minimal setup.
  • Ideal for internal tools, event check-ins, or rapid prototyping where UI speed matters.

qr-scanner is the performance choice for custom UIs.

  • Use it when design consistency is critical and you need to embed scanning into your own components.
  • Best for consumer-facing apps where bundle size and frame rate are priorities.

qrious is the standard for generation.

  • Use it whenever you need to display QR codes to users.
  • Pair it with qr-scanner if you need a lightweight scanning solution without the UI overhead of html5-qrcode.

qrcode-reader should generally be avoided in new frontend work.

  • Reserve it for legacy Node.js scripts or maintaining older applications.
  • Modern alternatives offer better performance and developer experience.

Final Thought: For a modern frontend architecture, the combination of qr-scanner (for reading) and qrious (for writing) often provides the best balance of performance and flexibility. However, if development speed is the priority, html5-qrcode remains a robust all-in-one contender.

How to Choose: html5-qrcode vs qr-scanner vs qrcode-reader vs qrious

  • html5-qrcode:

    Choose html5-qrcode if you need a comprehensive, all-in-one solution for scanning QR codes directly in the browser with a built-in UI. It is ideal for projects that require quick integration of camera scanning features without building custom video handling logic. It also supports generating QR codes, making it a versatile choice for apps needing both read and write capabilities in a single dependency.

  • qr-scanner:

    Choose qr-scanner if you prioritize performance and bundle size over built-in UI components. It is a lightweight library designed for developers who want full control over the video stream and UI rendering. This package is suitable for custom camera implementations where you need to integrate scanning into an existing design system without the overhead of a pre-built interface.

  • qrcode-reader:

    Avoid qrcode-reader for new browser-based projects as it is largely considered legacy and primarily optimized for Node.js environments or decoding static images rather than live camera streams. Only select this package if you are maintaining an older codebase that relies on its specific API for decoding QR codes from image files on the server side.

  • qrious:

    Choose qrious if your primary requirement is generating QR codes on the client side using HTML5 Canvas. It is not designed for scanning. This package is the best fit for applications that need to display dynamic QR codes (e.g., payment links, sharing profiles) with customization options like color and size, without needing any scanning functionality.

README for html5-qrcode

Html5-QRCode

Lightweight & cross platform QR Code and Bar code scanning library for the web

Use this lightweight library to easily / quickly integrate QR code, bar code, and other common code scanning capabilities to your web application.

Key highlights

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.

CircleCI GitHub issues GitHub tag (latest by date) GitHub Codacy Badge Gitter

GitHub all releases npm

Demo at scanapp.orgDemo at qrcode.minhazav.dev - Scanning different types of codes

We need your help!

image Help incentivise feature development, bug fixing by supporting the sponsorhip goals of this project. See list of sponsered feature requests here.

ko-fi

Documentation

The documentation for this project has been moved to scanapp.org/html5-qrcode-docs.

Supported platforms

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

PC / Mac

Firefox
Firefox
Chrome
Chrome
Safari
Safari
Opera
Opera
Edge
Edge

Android

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Opera
Opera
Opera-Mini
Opera Mini
UC
UC

IOS

Safari
Safari
Chrome
Chrome
Firefox
Firefox
Edge
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

Framework support

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.

Html5VueJsElectronJsReactLit

Supported Code formats

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.

CodeExample
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).

Description - View Demo

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:

  • Querying camera on the device (with user permissions)
  • Rendering live camera feed, with easy to use user interface for scanning
  • Supports scanning a different kind of QR codes, bar codes and other formats
  • Supports selecting image files from the device for scanning codes

How to use

Find detailed guidelines on how to use this library on scanapp.org/html5-qrcode-docs.

Demo


Scan this image or visit blog.minhazav.dev/research/html5-qrcode.html

For more information

Check these articles on how to use this library:

Screenshots

screenshot
Figure: Screenshot from Google Chrome running on MacBook Pro

Documentation

Find the full API documentation at scanapp.org/html5-qrcode-docs/docs/apis.

Extra optional configuration in start() method

Configuration 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 = 10

A.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 ratio

Use 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:

ValueAspect RatioUse Case
1.3333344:3Standard camera aspect ratio
1.77777816:9Full screen, cinematic
1.01:1Square 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 = false

By 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:

  • You are sure that the camera feed cannot be mirrored (Horizontally flipped)
  • You are facing performance issues with this enabled.

Here's an example of a normal and mirrored QR Code

Normal QR CodeMirrored QR Code

rememberLastUsedCamera β€” Boolean (Optional), default = true

If 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:

  • Limit support to either of Camera or File based scan.
  • Change default scan type.

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 | undefined

This 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.

Scanning only specific formats

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.

Scanning only QR code with Html5Qrcode

const 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);

Scanning only QR code and UPC codes with Html5QrcodeScanner

function 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);

Experimental features

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:

How to modify and build

  1. Code changes should only be made to /src only.

  2. Run npm install to install all dependencies.

  3. 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.

  4. Testing

    • Run npm test
    • Run the tests before sending a pull request, all tests should run.
    • Please add tests for new behaviors sent in PR.
  5. Send a pull request

    • Include code changes only to ./src. Do not change ./dist manually.
    • In the pull request add a comment like
    @all-contributors please add @mebjas for this new feature or tests
    
    • For calling out your contributions, the bot will update the contributions file.
    • Code will be built & published by the author in batches.

How to contribute

You can contribute to the project in several ways:

  • File issue ticket for any observed bug or compatibility issue with the project.
  • File feature request for missing features.
  • Take open bugs or feature request and work on it and send a Pull Request.
  • Write unit tests for existing codebase (which is not covered by tests today). Help wanted on this - read more.

Support πŸ’–

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).

webauthor@ ben-gy bujjivadu

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

Credits

The decoder used for the QR code reading is from Zxing-js https://github.com/zxing-js/library