Read saved QR images
Pass a Buffer or Uint8Array holding PNG, JPEG, WebP or GIF bytes to scan() to extract URLs, text and QR scannability diagnostics.
npm + 6 addons
Node.js 18+
In-process
MIT
Decode uploaded or local QR images inside backend routes and job queues using prebuilt Rust N-API addons.
Pass a Buffer or Uint8Array holding PNG, JPEG, WebP or GIF bytes to scan() to extract URLs, text and QR scannability diagnostics.
Async scan() executes native Rust decoding on libuv worker threads so HTTP routes stay responsive; scanSync() remains available for blocking scripts.
Bundles TypeScript types along with formats filtering, maxDimension and maxPixels limits, budgetMs control and AbortSignal cancellation.
Install the native npm package, read an image Buffer and await scan() without blocking the event loop.
Requires Node.js 18 or later. Install @qrcode-ai-com/qrcode-barcode-scanner on npm with optional dependencies enabled so npm resolves the prebuilt native addon for your machine or container.
Six prebuilt targets are published 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 toolchain is required.
npm install @qrcode-ai-com/qrcode-barcode-scanner
Avoid installing with --omit=optional: no ARM64 musl addon is shipped and there is no WASI fallback.
For browser web apps, camera capture or hosts without a matching native addon, use the separate JavaScript QR Code Scanner SDK WASM package.
Supply a Buffer or Uint8Array (PNG, JPEG, WebP or GIF) to scan(). Pass formats: ["qr_code"] to skip barcode readers, and tighten maxDimension and maxPixels whenever you handle public 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 work budgets are full (4000 ms), fast (800 ms) and frame (80 ms); pass budgetMs: 0 for an unbounded scan.
Supply signal (an AbortSignal) to reject queued scans with AbortError before they begin; a scan already in flight finishes normally.
For a QR image encoding https://qrcode-ai.com/, readQrImage resolves to ["https://qrcode-ai.com/"]. Check report.score for QR scannability diagnostics (null means unmeasured, never zero).
An image containing no QR code resolves to an empty detections array (confirm 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 check which readers are compiled in.
Caps and addon loading. Default image caps are 10,000 px per side and 64 million pixels; invalid options reject with [QRS-006]. When a platform addon is absent, loading throws Cannot find native binding rather than returning a [QRS-xxx] scan error.
Browser separation and MIT licence. Live camera capture belongs in the browser WASM package. Current releases use the MIT licence (with Apache-2.0 notices in LICENSING.md); read the Node.js package README and Node.js API docs.
Official package guides, ScanReport schema specification and licensing notices.
Native addons, supported platforms, 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 child process.
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 built and there is no WASI fallback.
Prefer async scan() inside HTTP servers, APIs and worker pools so Rust decoding runs on libuv worker threads without stalling the JavaScript event loop. Keep scanSync() for quick CLI scripts or isolated tasks where blocking the main thread is deliberate.
@qrcode-ai-com/qrcode-barcode-scanner loads compiled native Rust addons inside Node.js servers and reads encoded PNG, JPEG, WebP or GIF buffers. For browser web apps, camera feeds or environments lacking a native binary, switch to @qrcode-ai-com/qrcode-barcode-scanner-wasm (see the JavaScript QR Code Scanner SDK).
Yes. Built-in TypeScript declarations ship inside the npm package. Pass an AbortSignal via the signal option to scan() to cancel queued tasks before execution with an AbortError DOMException; any scan already running settles normally.
When no QR code is present, scan() resolves with an empty detections array (verify trace.budget_exhausted === false). Unreadable files, oversized uploads or unknown format names reject with [QRS-xxx] error codes, whereas a missing platform binary throws Cannot find native binding at require or import time.
No. Once installed, every decode executes locally in process with zero network requests, no QR Code AI account, no API key and no creation credits.
Yes. Current releases ship under the MIT licence for commercial and proprietary backend software, provided copyright and licence notices stay intact (check LICENSING.md for third-party Apache-2.0 notices). SDK usage is independent of QR Code AI’s paid creation plans and seven-day Premium trial.