qrcode
QR code generator for Node.js and the browser — generate QR codes as PNG images, SVGs, or terminal ASCII art.
qrcode
General JSQR code generator for Node.js and the browser — generate QR codes as PNG images, SVGs, or terminal ASCII art.
Fit
Bundle (gzip)
8.8 kB
23.5 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Adding QR code generation to a web app for URLs, payment links, or 2FA setup codes requires either an external service (with privacy/availability concerns) or a reliable client-side/server-side library.
What It Does
qrcode generates QR codes in multiple formats: PNG buffer/file, SVG string, canvas element (browser), or terminal ASCII art. It handles error correction levels, margin, color, and scale settings. Works identically in Node.js and the browser via its UMD build.
Installation
npm install qrcode
npm install -D @types/qrcodeUsage Example
import QRCode from 'qrcode';
// Generate a PNG data URL (for use in <img> src)
const dataUrl = await QRCode.toDataURL('https://myapp.com/invite/abc123', {
errorCorrectionLevel: 'H',
margin: 2,
color: { dark: '#000000', light: '#ffffff' },
});
// Generate SVG string
const svg = await QRCode.toString('https://myapp.com', { type: 'svg' });
// Save as PNG file
await QRCode.toFile('qr.png', 'https://myapp.com', { width: 300 });Related packages
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
archiverGeneral JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.