Read saved QR images
Pass a Buffer or Uint8Array of PNG, JPEG, WebP or GIF bytes to scan() and receive decoded URLs, text and QR quality diagnostics.
npm + 6 addons
Node.js 18+
In-process
MIT
Decode uploaded or local QR images in server routes and worker queues using pre-built Rust N-API addons.
Pass a Buffer or Uint8Array of PNG, JPEG, WebP or GIF bytes to scan() and receive decoded URLs, text and QR quality diagnostics.
Async scan() runs native Rust decoding on libuv worker threads so HTTP handlers stay responsive; scanSync() is ready for blocking scripts.
Ships TypeScript declarations plus formats filtering, maxDimension/maxPixels caps, budgetMs control and AbortSignal support.
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 npm selects the pre-built native addon for your host.
Six pre-built 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 Rust compiler is needed.
npm install @qrcode-ai-com/qrcode-barcode-scanner
Do not install with --omit=optional: an ARM64 musl addon is not provided and there is no WASI fallback.
For browser apps, camera frames or hosts without a native addon, 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 skip barcode readers, and lower maxDimension and maxPixels when scanning 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 tasks with AbortError before execution starts; a running scan finishes normally.
For a QR image encoding https://qrcode-ai.com/, readQrImage resolves to ["https://qrcode-ai.com/"]. Inspect report.score for QR quality diagnostics (null means unmeasured, never zero).
An image with no QR code resolves with an empty detections array (confirm report.trace.budget_exhausted === false). Invalid inputs or options reject with [QRS-xxx] error codes.
Async vs sync API. Use scan() to keep native Rust work on libuv worker threads, scanSync() only when deliberate blocking is acceptable, and capabilities() to inspect compiled readers.
Limits 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 load time rather than a [QRS-xxx] scan fault.
Browser separation and MIT licence. Raw camera capture belongs in the browser WASM package. Current releases are MIT-licensed (with Apache-2.0 notices in LICENSING.md); see the Node.js package README and Node.js API docs.
Official package documentation, ScanReport specification and licensing references.
Native addons, platforms, libuv async, TypeScript, browser WASM and licensing.
It is QR Code AI’s open-source MIT native Node.js package (@qrcode-ai-com/qrcode-barcode-scanner) backed by pre-built Rust N-API addons. It decodes QR codes, Micro QR, rMQR and 16 barcode formats directly in Node.js 18+ without spawning a CLI subprocess.
Six pre-built native 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() in servers, APIs and worker pools so Rust decoding runs on libuv worker threads without blocking the JavaScript event loop. Reserve scanSync() for simple CLI scripts or isolated tasks where blocking the calling thread is intentional.
@qrcode-ai-com/qrcode-barcode-scanner runs native compiled Rust addons in Node.js servers and accepts encoded PNG, JPEG, WebP or GIF buffers. For browser apps, camera capture or hosts without a native addon, use @qrcode-ai-com/qrcode-barcode-scanner-wasm (see the JavaScript QR Code Scanner SDK).
Yes. TypeScript definitions ship inside the package. Pass signal (an AbortSignal) to scan() to abort queued tasks before execution with an AbortError DOMException; a scan that has already started settles normally.
No code found resolves with an empty detections array (check trace.budget_exhausted === false). Unreadable files, oversized images or unknown format names reject with [QRS-xxx] codes, while missing native binaries throw Cannot find native binding at load time.
No. Once installed, all decoding runs locally in process with zero outbound network requests, no QR Code AI account, no API key and no creation credits.
Yes. Current releases are MIT-licensed for commercial and proprietary software while retaining copyright and licence notices (see LICENSING.md for third-party Apache-2.0 notices). SDK use is separate from QR Code AI’s paid creation plans and seven-day Premium trial.