Read saved QR images
Pass a Buffer or Uint8Array of PNG, JPEG, WebP or GIF bytes to scan() to extract decoded URLs, plain text and QR quality diagnostics.
npm + 6 addons
Node.js 18+
In-process
MIT
Decode uploaded or local QR images inside server routes and job queues with prebuilt Rust N-API addons.
Pass a Buffer or Uint8Array of PNG, JPEG, WebP or GIF bytes to scan() to extract decoded URLs, plain text and QR quality diagnostics.
Async scan() executes native Rust decoding on libuv worker threads so HTTP routes stay snappy; scanSync() is available for blocking scripts.
Bundles TypeScript types alongside formats filtering, maxDimension/maxPixels caps, budgetMs control and AbortSignal cancellation.
Install the native npm package, read an image Buffer and await scan() off the event loop.
Requires Node.js 18 or later. Install @qrcode-ai-com/qrcode-barcode-scanner on npm with optional dependencies enabled so your package manager pulls the matching prebuilt native addon for your host.
Six prebuilt targets ship on npm: macOS (darwin-arm64, darwin-x64), GNU/Linux (linux-arm64-gnu, linux-x64-gnu), Linux musl x64 (linux-x64-musl) and Windows x64 (win32-x64-msvc). No local Rust toolchain is required.
npm install @qrcode-ai-com/qrcode-barcode-scanner
Never install with --omit=optional: ARM64 musl has no prebuilt addon and there is no WASI fallback.
For browser web apps, live camera frames or hosts without a native binary, use the separate JavaScript QR Code Scanner SDK WASM package.
Pass a Buffer or Uint8Array (PNG, JPEG, WebP or GIF) to scan(). Set formats: ["qr_code"] to bypass barcode decoders, and tighten maxDimension and maxPixels whenever handling untrusted user uploads.
import { readFile } from "node:fs/promises";
import { scan } from "@qrcode-ai-com/qrcode-barcode-scanner";
export async function readQrImage(filePath) {
const bytes = await readFile(filePath);
const report = await scan(bytes, {
profile: "full",
formats: ["qr_code"],
maxDimension: 4096,
maxPixels: 16_000_000,
});
return report.detections
.filter((d) => d.content.charset !== "unknown")
.map((d) => d.content.text);
}
Default profile budgets are full (4000 ms), fast (800 ms) and frame (80 ms); pass budgetMs: 0 for an unbounded scan.
Pass signal (an AbortSignal) to reject queued scans with AbortError before they begin; an already-running scan runs to completion.
For a QR image encoding https://qrcode-ai.com/, readQrImage resolves to ["https://qrcode-ai.com/"]. Read report.score for QR quality diagnostics (null means unmeasured, never zero).
An image with no QR code resolves to an empty detections array (verify report.trace.budget_exhausted === false). Invalid inputs or options reject with [QRS-xxx] error codes.
Async versus sync API. Call scan() to offload native Rust decoding onto libuv worker threads, reserve scanSync() for deliberate blocking scripts and call capabilities() to inspect compiled readers.
Input caps and addon loading. Default caps are 10,000 px per side and 64 million pixels; invalid options reject with [QRS-006]. A missing platform addon throws Cannot find native binding at require/import time rather than a [QRS-xxx] scan error.
Browser separation and MIT licence. Live camera capture belongs in the browser WASM package. Current releases ship under the MIT licence (with Apache-2.0 notices in LICENSING.md); read the Node.js package README and Node.js API documentation.
Official package guides, ScanReport specification and licensing references.
Native addons, supported hosts, libuv async, TypeScript, browser WASM and licensing.
It is QR Code AI’s open-source MIT-licensed native Node.js package (@qrcode-ai-com/qrcode-barcode-scanner) powered by prebuilt Rust N-API addons. It decodes QR codes, Micro QR, rMQR and 16 barcode formats directly inside Node.js 18+ without spawning any CLI subprocess.
Six prebuilt optional packages are published on npm: macOS Apple Silicon (darwin-arm64), macOS Intel (darwin-x64), GNU/Linux ARM64 (linux-arm64-gnu), GNU/Linux x64 (linux-x64-gnu), Linux musl x64 (linux-x64-musl) and Windows x64 (win32-x64-msvc). ARM64 musl is not provided, and there is no WASI fallback.
Use async scan() across API servers, web backends and worker pools so Rust decoding runs on libuv worker threads without blocking the event loop. Keep scanSync() for short CLI scripts or isolated batch jobs where blocking the main thread is deliberate.
@qrcode-ai-com/qrcode-barcode-scanner executes compiled native Rust addons inside Node.js backends and takes encoded PNG, JPEG, WebP or GIF buffers. For browser web apps, live camera frames or hosts lacking a native addon, use @qrcode-ai-com/qrcode-barcode-scanner-wasm via the JavaScript QR Code Scanner SDK.
Yes. TypeScript declarations are bundled straight inside the package. Pass signal (an AbortSignal) to scan() to abort queued jobs with an AbortError DOMException before execution starts; any scan already in flight finishes normally.
When no QR code is found, scan() resolves with an empty detections array (confirm trace.budget_exhausted === false). Unreadable files, oversized images or unknown format keys reject with [QRS-xxx] codes, while a missing native binary throws Cannot find native binding when the module loads.
No. Once installed, decoding runs entirely in process with zero outbound network calls, no QR Code AI account, no API key and no creation credits.
Yes. Current releases ship under the MIT licence for commercial and proprietary Node.js apps provided copyright and licence notices are retained (see LICENSING.md for third-party Apache-2.0 notices). SDK usage is completely separate from QR Code AI’s paid creation plans and seven-day Premium trial.