qr-code-styling vs qr-scanner vs qrious vs html5-qrcode vs jsqr vs qrcode-reader
QR Code Scanning and Generation in Web Applications
qr-code-stylingqr-scannerqrioushtml5-qrcodejsqrqrcode-readerSimilar 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
qr-code-styling481,1412,968516 kB1172 years agoMIT
qr-scanner263,8912,895524 kB119-MIT
qrious37,4651,617-449 years agoGPL-3.0
html5-qrcode06,2412.63 MB4474 years agoApache-2.0
jsqr04,041-985 years agoApache-2.0
qrcode-reader0281-179 years agoApache-2.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: qr-code-styling vs qr-scanner vs qrious vs html5-qrcode vs jsqr vs qrcode-reader

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

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

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

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

README for qr-code-styling

QR Code Styling

Version

JavaScript library for generating QR codes with a logo and styling.

Try it here https://qr-code-styling.com

If you have issues / suggestions / notes / questions, please open an issue or contact me. Let's create a cool library together.

Examples

Extensions

If you would like to use additional stiles, you can connect extensions.

qr-border-plugin

Installation

npm install qr-code-styling

Usage

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>QR Code Styling</title>
    <script type="text/javascript" src="https://unpkg.com/qr-code-styling@1.5.0/lib/qr-code-styling.js"></script>
</head>
<body>
<div id="canvas"></div>
<script type="text/javascript">

    const qrCode = new QRCodeStyling({
        width: 300,
        height: 300,
        type: "svg",
        data: "https://www.facebook.com/",
        image: "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg",
        dotsOptions: {
            color: "#4267b2",
            type: "rounded"
        },
        backgroundOptions: {
            color: "#e9ebee",
        },
        imageOptions: {
            crossOrigin: "anonymous",
            margin: 20
        }
    });

    qrCode.append(document.getElementById("canvas"));
    qrCode.download({ name: "qr", extension: "svg" });
</script>
</body>
</html>

React example (Codesandbox)

Angular example (Codesandbox)


React example (source)

Angular example (source)

Vue example (source)

Node.js example (source)

Next.js example (source)


API Documentation

QRCodeStyling instance

new QRCodeStyling(options) => QRCodeStyling

ParamTypeDescription
optionsobjectInit object

options structure

PropertyTypeDefault ValueDescription
widthnumber300Size of canvas
heightnumber300Size of canvas
typestring ('canvas' 'svg')canvasThe type of the element that will be rendered
shapestring (`'square' 'circle')squareThe shape of the qr-code, circle shape adds rundom extra dots arround
datastringThe data will be encoded to the QR code
imagestringThe image will be copied to the center of the QR code
marginnumber0Margin around canvas
qrOptionsobjectOptions will be passed to qrcode-generator lib
imageOptionsobjectSpecific image options, details see below
dotsOptionsobjectDots styling options
cornersSquareOptionsobjectSquare in the corners styling options
cornersDotOptionsobjectDots in the corners styling options
backgroundOptionsobjectQR background styling options
nodeCanvasnode-canvasOnly specify when running on a node server for canvas type, please refer to node section below
jsDomjsdomOnly specify when running on a node server for svg type, please refer to node section below

options.qrOptions structure

PropertyTypeDefault Value
typeNumbernumber (0 - 40)0
modestring ('Numeric' 'Alphanumeric' 'Byte' 'Kanji')
errorCorrectionLevelstring ('L' 'M' 'Q' 'H')'Q'

options.imageOptions structure

PropertyTypeDefault ValueDescription
hideBackgroundDotsbooleantrueHide all dots covered by the image
imageSizenumber0.4Coefficient of the image size. Not recommended to use ove 0.5. Lower is better
marginnumber0Margin of the image in px
crossOriginstring('anonymous' 'use-credentials')Set "anonymous" if you want to download QR code from other origins.
saveAsBlobbooleantrueSaves image as base64 blob in svg type, see bellow

When QR type is svg, the image may not load in certain applications as it is saved as a url, and some svg applications will not render url images for security reasons. Setting saveAsBlob to true will instead save the image as a blob, allowing it to render correctly in more places, but will also increase the file size.

options.dotsOptions structure

PropertyTypeDefault ValueDescription
colorstring'#000'Color of QR dots
gradientobjectGradient of QR dots
typestring ('rounded' 'dots' 'classy' 'classy-rounded' 'square' 'extra-rounded')'square'Style of QR dots
roundSizebooleantrueWhether to round dots size to integer. true value might create extra margin around qr code. If false, shape-rendering="crispEdges" will be applied to SVG element.

options.backgroundOptions structure

PropertyTypeDefault Value
colorstring ('#fff' 'rgb(255,255,255)' 'transparent')'#fff'
gradientobject

options.cornersSquareOptions structure

PropertyTypeDefault ValueDescription
colorstringColor of Corners Square
gradientobjectGradient of Corners Square
typestring ('dot' 'square' 'extra-rounded' 'rounded' 'dots' 'classy' 'classy-rounded')Style of Corners Square

options.cornersDotOptions structure

PropertyTypeDefault ValueDescription
colorstringColor of Corners Dot
gradientobjectGradient of Corners Dot
typestring ('dot' 'square' 'rounded' 'dots' 'classy' 'classy-rounded' 'extra-rounded')Style of Corners Dot

Gradient structure

options.dotsOptions.gradient

options.backgroundOptions.gradient

options.cornersSquareOptions.gradient

options.cornersDotOptions.gradient

PropertyTypeDefault ValueDescription
typestring ('linear' 'radial')"linear"Type of gradient spread
rotationnumber0Rotation of gradient in radians (Math.PI === 180 degrees)
colorStopsarray of objectsGradient colors. Example [{ offset: 0, color: 'blue' }, { offset: 1, color: 'red' }]

Gradient colorStops structure

options.dotsOptions.gradient.colorStops[]

options.backgroundOptions.gradient.colorStops[]

options.cornersSquareOptions.gradient.colorStops[]

options.cornersDotOptions.gradient.colorStops[]

PropertyTypeDefault ValueDescription
offsetnumber (0 - 1)Position of color in gradient range
colorstringColor of stop in gradient range

QRCodeStyling methods

QRCodeStyling.append(container) => void

ParamTypeDescription
containerDOM elementThis container will be used for appending of the QR code

QRCodeStyling.getRawData(extension) => Promise<Blob>

ParamTypeDefault ValueDescription
extensionstring ('png' 'jpeg' 'webp' 'svg')'png'Blob type on browser, Buffer type on Node

QRCodeStyling.update(options) => void

ParamTypeDescription
optionsobjectThe same options as for initialization

QRCodeStyling.applyExtension(extension) => void

ParamTypeDescription
extension(svg, options) => voidExtension is a function that takes svg and previously applied options and modifies an svg

applyExtension example

const extension = (svg, options) => {
    const { width, height } = options;
    const size = Math.min(width, height);
    const border = document.createElementNS("http://www.w3.org/2000/svg", "rect");
    const borderAttributes = {
        "fill": "none",
        "x": (width - size + 40) / 2,
        "y": (height - size + 40) / 2,
        "width": size - 40,
        "height": size - 40,
        "stroke": 'black',
        "stroke-width": 40,
        "rx": 100,
    };
    Object.keys(borderAttributes).forEach(attribute => {
      border.setAttribute(attribute, borderAttributes[attribute]);
    });
    svg.appendChild(border);
};

QRCodeStyling.deleteExtension() => void

QRCodeStyling.download(downloadOptions) => Promise<void>

ParamTypeDescription
downloadOptionsobjectOptions with extension and name of file (not required)

Promise returned will resolve into the data URI of the QR code image.

downloadOptions structure

PropertyTypeDefault ValueDescription
namestring'qr'Name of the downloaded file
extensionstring ('png' 'jpeg' 'webp' 'svg')'png'File extension

Building this repo

If you get an error running npm install referring to node-pre-gyp, this is caused by an attempt to compile the canvas dependency. See Compiling instructions in the README. For example on MacOS you need to install dependencies: brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman.

Node Support

You can use this on a node server by passing through the node-canvas or jsdom object depending if your creating a non-svg or svg respectively. You must pass both if using imageOptions.saveAsBlob.

Calling getRawData in node will return a Buffer instead of a Blob.

const { QRCodeStyling } = require("qr-code-styling/lib/qr-code-styling.common.js");
const nodeCanvas = require("canvas");
const { JSDOM } = require("jsdom");
const fs = require("fs");

const options = {
    width: 300,
    height: 300,
    data: "https://www.facebook.com/",
    image: "https://upload.wikimedia.org/wikipedia/commons/5/51/Facebook_f_logo_%282019%29.svg",
    dotsOptions: {
        color: "#4267b2",
        type: "rounded"
    },
    backgroundOptions: {
        color: "#e9ebee",
    },
    imageOptions: {
        crossOrigin: "anonymous",
        margin: 20
    }
}

// For canvas type
const qrCodeImage = new QRCodeStyling({
    jsdom: JSDOM, // this is required
    nodeCanvas, // this is required,
    ...options,
    imageOptions: {
        saveAsBlob: true,
        crossOrigin: "anonymous",
        margin: 20
    },
});

qrCodeImage.getRawData("png").then((buffer) => {
  fs.writeFileSync("test.png", buffer);
});

// For svg type
const qrCodeSvg = new QRCodeStyling({
    jsdom: JSDOM, // this is required
    type: "svg",
    ...options
});

qrCodeSvg.getRawData("svg").then((buffer) => {
  fs.writeFileSync("test.svg", buffer);
});

// For svg type with the inner-image saved as a blob
// (inner-image will render in more places but file will be larger)
const qrCodeSvgWithBlobImage = new QRCodeStyling({
    jsdom: JSDOM, // this is required
    nodeCanvas, // this is required
    type: "svg",
    ...options,
    imageOptions: {
        saveAsBlob: true,
        crossOrigin: "anonymous",
        margin: 20
    }
});

qrCodeSvgWithBlobImage.getRawData("svg").then((buffer) => {
  fs.writeFileSync("test_blob.svg", buffer);
});

License

MIT License. Copyright (c) 2021 Denys Kozak