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.
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.
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.
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.
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
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);
}
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 });
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.
| Package | Primary Use | Camera Built-in | Styling Options | Maintenance |
|---|---|---|---|---|
html5-qrcode | Scanning | ✅ Yes | N/A | ✅ Active |
qr-scanner | Scanning | ❌ No | N/A | ✅ Active |
jsqr | Scanning | ❌ No | N/A | ⚠️ Stable |
qrcode-reader | Scanning | ❌ No | N/A | ❌ Inactive |
qr-code-styling | Generation | N/A | ✅ Advanced | ✅ Active |
qrious | Generation | N/A | ⚠️ Basic | ⚠️ Stable |
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.
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.
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.
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.
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.
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.
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.
This was started as a port of Lazarsoft’s qrcode reader.
It is a maintained fork, so feel free to open issues or PR !
npm install qrcode-reader
var QrCode = require('qrcode-reader');
Create a new instance of QrCode:
var qr = new QrCode();
Set its callback to a custom function:
qr.callback = function(error, result) {
if(error) {
console.log(error)
return;
}
console.log(result)
}
You have to use an external imageparser
You can use npm install --save jimp which doesn't have any dependency (runs in pure node).
var Jimp = require("jimp");
var buffer = fs.readFileSync(__dirname + '/image.png');
Jimp.read(buffer, function(err, image) {
if (err) {
console.error(err);
// TODO handle error
}
var qr = new QrCode();
qr.callback = function(err, value) {
if (err) {
console.error(err);
// TODO handle error
}
console.log(value.result);
console.log(value);
};
qr.decode(image.bitmap);
});
You can use npm install --save image-parser, which depends on lwip or graphicsmagick
var ImageParser = require("image-parser");
var buffer = fs.readFileSync(__dirname + '/image.png');
var img = new ImageParser(img);
img.parse(function(err) {
if (err) {
console.error(err);
// TODO handle error
}
var qr = new QrCode();
qr.callback = function(err, value) {
if (err) {
console.error(err);
// TODO handle error
return done(err);
}
console.log(value.result);
console.log(value);
};
qr.decode({width: img.width(), height: img.height()}, img._imgBuffer);
});
Since the browser contains the Image global, we can use it to open images with URL, Data URI, ...
Decode an image by its URL or Data URI:
qr.decode(url or DataURL);
Decode an image by context.getImageData: Works with web workers.
var context = canvas.getContext("2d"); var data = context.getImageData(0, 0, width, height);
qr.decode(data);
====================
If you want, you can build the script yourself.
First clone the repository, then from the directory of this repository, do:
npm install
To run the build process and generate a JavaScript file called dist/index.js you can run from node:
npm run build
To run the tests:
npm test
The generated file dist/index.js works in the browser.
You will have access to the global variable QrCode if you do the following in your HTML:
```
\`\`\`See examples/browser-upload/index.html for a very basic example using a file upload.
See CHANGELOG.md.