html5-qrcode vs jsqr vs qr-code-styling vs qr-scanner vs qrcode-reader vs qrious
QR Code Scanning and Generation in Web Applications
html5-qrcodejsqrqr-code-stylingqr-scannerqrcode-readerqriousSimilar Packages:

QR Code Scanning and Generation in Web Applications

These six npm packages cover the full spectrum of QR code functionality in web applications β€” from scanning QR codes using device cameras to generating styled QR codes for display. html5-qrcode and qr-scanner focus on camera-based scanning with different approaches to browser compatibility. jsqr and qrcode-reader are lower-level decoding libraries that work with image data. qr-code-styling and qrious handle QR code generation, with the former emphasizing visual customization and the latter focusing on lightweight canvas/SVG output. Together, they represent different architectural choices for teams building QR code features into their applications.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
html5-qrcode06,1602.63 MB4403 years agoApache-2.0
jsqr04,013-975 years agoApache-2.0
qr-code-styling02,849516 kB113a year agoMIT
qr-scanner02,874524 kB118-MIT
qrcode-reader0283-179 years agoApache-2.0
qrious01,622-439 years agoGPL-3.0

QR Code Libraries in Web Apps: Scanning and Generation Compared

Building QR code features into web applications means making two key decisions: how to scan codes from camera or images, and how to generate codes for display. The six packages we're comparing split cleanly into these two categories. Let's examine how they handle real-world scenarios.

πŸ“· Camera Access and Scanning Setup

Getting camera access in the browser requires handling permissions, device selection, and video stream management. Different packages take different approaches to this complexity.

html5-qrcode provides a complete UI wrapper around camera access. You get built-in camera selection, permission handling, and a scanning viewport.

import { Html5Qrcode } from 'html5-qrcode';

const html5Qrcode = new Html5Qrcode('reader');
html5Qrcode.start(
  { facingMode: 'environment' },
  { fps: 10, qrbox: 250 },
  (decodedText) => console.log(decodedText)
);

qr-scanner gives you more control but requires manual camera setup. It works with a video element you provide and focuses purely on decoding frames.

import QrScanner from 'qr-scanner';

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

jsqr doesn't handle camera access at all. You feed it image data from any source β€” a video frame, uploaded image, or canvas.

import jsQR from 'jsqr';

const imageData = ctx.getImageData(0, 0, width, height);
const code = jsQR(imageData.data, width, height);
if (code) console.log(code.data);

qrcode-reader works similarly to jsqr but with an older callback-based API. You pass image data and get results through a callback.

import QrCode from 'qrcode-reader';

const qr = new QrCode();
qr.callback = (err, value) => {
  if (!err) console.log(value.result);
};
qr.decode(imageData);

qr-code-styling and qrious don't scan at all β€” they only generate QR codes for display.

🎨 QR Code Generation and Styling

When generating QR codes, you need to decide between basic functionality and visual customization. This is where the generation libraries diverge significantly.

qr-code-styling excels at branded, customized QR codes. You can change dot patterns, add logos, apply gradients, and adjust corners.

import QRCodeStyling from 'qr-code-styling';

const qrCode = new QRCodeStyling({
  data: 'https://example.com',
  dotsOptions: { color: '#4267b2', type: 'rounded' },
  image: '/logo.png',
  imageOptions: { imageSize: 0.4 }
});
qrCode.append(document.getElementById('canvas'));

qrious focuses on simplicity. You get canvas or SVG output with basic color and size options, but no advanced styling.

import QRious from 'qrious';

const qr = new QRious({
  element: document.getElementById('canvas'),
  value: 'https://example.com',
  size: 200,
  foreground: '#000000'
});

The other four packages (html5-qrcode, jsqr, qr-scanner, qrcode-reader) don't generate QR codes β€” they only read them.

⚑ Performance and Bundle Considerations

Bundle size and runtime performance matter differently depending on your use case. Scanning libraries need to process video frames quickly, while generation libraries run once per QR code created.

jsqr has no dependencies and minimal bundle impact. It's pure JavaScript with no external requirements.

// jsqr: Zero dependencies
import jsQR from 'jsqr';
// Bundle: ~15KB minified

qr-scanner uses Web Workers for decoding, keeping the main thread free during scanning.

// qr-scanner: Web Worker support
import QrScanner from 'qr-scanner';
QrScanner.WORKER_PATH = '/qr-scanner-worker.min.js';

html5-qrcode includes UI components and camera handling, resulting in a larger bundle but less custom code.

// html5-qrcode: Full-featured with UI
import { Html5QrcodeScanner } from 'html5-qrcode';
const scanner = new Html5QrcodeScanner();

qr-code-styling includes canvas manipulation and image processing for customization features.

// qr-code-styling: Advanced rendering
import QRCodeStyling from 'qr-code-styling';
// More bundle weight for styling features

qrious stays lightweight with basic canvas/SVG rendering.

// qrious: Minimal generator
import QRious from 'qrious';
// Small bundle for basic generation

qrcode-reader is older and hasn't received modern optimizations. It works but lacks performance improvements found in newer libraries.

// qrcode-reader: Legacy library
import QrCode from 'qrcode-reader';
// Consider newer alternatives for new projects

πŸ”„ Error Handling and Edge Cases

QR code scanning fails often β€” poor lighting, damaged codes, or camera issues. How each library handles these situations affects user experience.

html5-qrcode provides built-in error callbacks and UI feedback for scanning failures.

html5Qrcode.start(
  config,
  { fps: 10, qrbox: 250 },
  (text) => console.log('Success:', text),
  (error) => console.warn('Scan error:', error)
);

qr-scanner throws errors you need to catch manually, giving you full control over error UI.

try {
  await scanner.start();
} catch (error) {
  console.error('Camera access failed:', error);
}

jsqr returns null when no QR code is found β€” no exceptions, just check the result.

const code = jsQR(imageData.data, width, height);
if (!code) {
  // No QR code detected, continue scanning
}

qrcode-reader uses callbacks for both success and error cases.

qr.callback = (err, value) => {
  if (err) console.error('Decode failed:', err);
  else console.log('Result:', value.result);
};

qr-code-styling and qrious throw errors on invalid data, which you should wrap in try-catch blocks.

try {
  const qr = new QRious({ value: 'https://example.com' });
} catch (error) {
  console.error('Invalid QR data:', error);
}

🌐 Browser Compatibility

Not all libraries work equally well across browsers. Camera APIs and canvas features have varying support.

html5-qrcode targets broad compatibility including older browsers. It includes fallbacks for devices without full MediaStream support.

// html5-qrcode: Broad browser support
// Works on iOS Safari, Android Chrome, desktop browsers
const scanner = new Html5Qrcode('reader');

qr-scanner requires modern browsers with full MediaStream and Web Worker support.

// qr-scanner: Modern browsers only
// iOS 11+, Chrome 53+, Firefox 55+
const scanner = new QrScanner(video, resultHandler);

jsqr works anywhere JavaScript runs since it only processes image data.

// jsqr: Universal compatibility
// No browser APIs required - pure JS
const code = jsQR(data, width, height);

qrcode-reader has similar universal compatibility but hasn't been tested against newer browser versions.

// qrcode-reader: Legacy compatibility
// Works broadly but unmaintained
qr.decode(imageData);

qr-code-styling and qrious work in any browser with canvas support, which is nearly universal today.

// Both: Canvas-based generation
// Works in all modern browsers
const qr = new QRious({ element: canvas });

πŸ› οΈ Maintenance Status

Library maintenance affects long-term project health. Some packages in this comparison are no longer actively developed.

html5-qrcode is actively maintained with regular updates and issue responses. Safe for new projects.

qr-scanner is actively maintained with recent releases and modern API patterns. Good choice for greenfield development.

jsqr receives occasional updates but is relatively stable. The core decoding logic doesn't change often.

qr-code-styling is actively maintained with new styling features added regularly.

qrious is stable but sees infrequent updates. The simple feature set means fewer changes are needed.

qrcode-reader is no longer actively maintained. Avoid for new projects β€” use jsqr or qr-scanner instead.

πŸ“Š Summary: Scanning vs Generation

PackagePrimary UseCamera Built-inStyling OptionsMaintenance
html5-qrcodeScanningβœ… YesN/Aβœ… Active
qr-scannerScanning❌ NoN/Aβœ… Active
jsqrScanning❌ NoN/A⚠️ Stable
qrcode-readerScanning❌ NoN/A❌ Inactive
qr-code-stylingGenerationN/Aβœ… Advancedβœ… Active
qriousGenerationN/A⚠️ Basic⚠️ Stable

πŸ’‘ The Big Picture

For scanning QR codes, you have three viable options today:

  • html5-qrcode β€” Best for teams that want everything handled. You get camera UI, permissions, and scanning in one package. Ideal for customer-facing apps where reliability matters more than bundle size.

  • qr-scanner β€” Best for teams that want control. You manage the camera UI but get fast, modern decoding with Web Worker support. Ideal for apps where you already have video handling infrastructure.

  • jsqr β€” Best for specialized cases. Use it when you're processing static images or already have a custom video pipeline. Avoid it if you need camera handling.

For generating QR codes, you have two clear choices:

  • qr-code-styling β€” Best when appearance matters. Marketing materials, branded apps, or any scenario where the QR code needs to match your design system.

  • qrious β€” Best for functional needs. Admin panels, internal tools, or any scenario where the QR code just needs to work without visual flair.

Avoid qrcode-reader for new projects. It's served its purpose but lacks modern optimizations and active maintenance.

Final Thought: Most production apps will combine one scanning library with one generation library. A common pattern is html5-qrcode for scanning paired with qrious for basic generation, or qr-scanner with qr-code-styling for apps that need both performance and branded QR codes.

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

  • html5-qrcode:

    Choose html5-qrcode if you need a full-featured scanning solution with built-in camera handling, UI controls, and broad browser support. It's ideal for production apps where you want minimal setup and don't mind a larger bundle. The library handles permissions, camera selection, and scanning state management out of the box, making it the safest choice for teams that want reliability over minimalism.

  • jsqr:

    Choose jsqr if you need a lightweight, dependency-free decoder that works with raw image data. It's perfect for scenarios where you already have image frames from another source (like a video stream you're managing yourself) and just need decoding logic. Avoid it if you want built-in camera handling β€” you'll need to wire that up separately.

  • qr-code-styling:

    Choose qr-code-styling if visual customization is your priority β€” you need branded QR codes with custom colors, logos, gradients, or dot patterns. It's the best option for marketing materials, customer-facing apps, or any scenario where the QR code's appearance matters. The trade-off is a larger bundle and more complex API than basic generators.

  • qr-scanner:

    Choose qr-scanner if you want a modern, lightweight scanner with good performance and Web Worker support. It's ideal for teams that value bundle size and are comfortable managing camera access themselves. The library is actively maintained and uses newer browser APIs, making it a solid choice for greenfield projects targeting modern browsers.

  • qrcode-reader:

    Avoid qrcode-reader for new projects β€” it's no longer actively maintained and lacks modern browser optimizations. Only consider it if you're maintaining legacy code that already depends on it. For any new scanning feature, evaluate html5-qrcode or qr-scanner instead, as they offer better performance and ongoing support.

  • qrious:

    Choose qrious if you need a simple, lightweight QR code generator with canvas and SVG support. It's perfect for internal tools, admin panels, or any scenario where basic QR generation is needed without visual customization. The API is straightforward and the bundle is small, but don't expect advanced styling features.

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