Zero-dependency QR code generator written in TypeScript. Implements ISO/IEC 18004 standard.
Migrated from
qr-pure— if you were usingqr-pure, simply change your import to@qr-plus/core. The API is identical.
npm install @qr-plus/core
import { generateQR, renderToSVG, renderToTerminal } from "@qr-plus/core";
// Generate QR matrix
const { matrix } = generateQR("Hello World");
// Render as SVG string
const svg = renderToSVG("Hello World", { scale: 10 });
// Print to terminal
console.log(renderToTerminal("Hello World"));
import { QRCode } from "@qr-plus/core";
const qr = new QRCode("Hello World", {
errorCorrectionLevel: "H", // L, M, Q, H
version: "auto", // 1-40 or 'auto'
mode: "auto", // numeric, alphanumeric, byte, or 'auto'
mask: "auto", // 0-7 or 'auto'
});
const { matrix, version, size, mode, maskPattern } = qr.generate();
import { QRCode, CanvasRenderer } from "@qr-plus/core";
const qr = new QRCode("Hello World");
const { matrix } = qr.generate();
const canvas = document.getElementById("qr-canvas") as HTMLCanvasElement;
CanvasRenderer.render(canvas, matrix, {
scale: 10,
margin: 4,
darkColor: "#000000",
lightColor: "#ffffff",
});
import { SVGRenderer } from "@qr-plus/core";
// Standard squares
const svg = SVGRenderer.render(matrix, { scale: 10 });
// Rounded modules
SVGRenderer.render(matrix, { moduleShape: "rounded", cornerRadius: 0.3 });
// Circle or dot modules
SVGRenderer.render(matrix, { moduleShape: "circle" });
SVGRenderer.render(matrix, { moduleShape: "dot" });
import { TerminalRenderer } from "@qr-plus/core";
// Unicode blocks (best contrast)
console.log(TerminalRenderer.render(matrix));
// Compact mode (half height)
console.log(TerminalRenderer.render(matrix, { style: "compact" }));
// ASCII (max compatibility)
console.log(TerminalRenderer.render(matrix, { style: "ascii" }));
// Inverted for dark backgrounds
console.log(TerminalRenderer.render(matrix, { invert: true }));
new QRCode(data: string, options?: QRCodeOptions)
Options:
errorCorrectionLevel: 'L' | 'M' | 'Q' | 'H' (default: 'M')version: 1-40 | 'auto' (default: 'auto')mode: 'numeric' | 'alphanumeric' | 'byte' | 'auto' (default: 'auto')mask: 0-7 | 'auto' (default: 'auto')Methods:
generate(): Returns { matrix, version, size, mode, maskPattern }generateQR(content, options?) // → QRCodeResult
renderToCanvas(canvas, content, options?) // → void
renderToSVG(content, options?) // → string
renderToTerminal(content, options?) // → string
CanvasRenderer.render(canvas, matrix, options?)
CanvasRenderer.toDataURL(matrix, options?)
CanvasRenderer.toBlob(matrix, options?)
SVGRenderer.render(matrix, options?)
// options: scale, margin, darkColor, lightColor, moduleShape, cornerRadius
TerminalRenderer.render(matrix, options?)
// options: style ('unicode' | 'compact' | 'ascii'), margin, invert
This package is part of the @qr-plus monorepo. See the root README for setup instructions.
# From the monorepo root
pnpm install # Install all dependencies
pnpm run build # Build all packages
pnpm run test # Run all tests (unit + integration + E2E)
pnpm run typecheck # Type check
pnpm run lint # Lint
# Or run commands scoped to the core package
pnpm --filter @qr-plus/core test
pnpm --filter @qr-plus/core build
MIT