Read a QR image
Let users select a screenshot, downloaded image or QR photo. Receive its encoded text so your interface can display it or pass it to the next step.
Let users read an image, scan through your camera interface and use the decoded content without leaving your app.
Let users select a screenshot, downloaded image or QR photo. Receive its encoded text so your interface can display it or pass it to the next step.
Pass captured RGBA pixels to scan_frame, or use the package’s /camera controller and overlay while your app manages permissions.
Return a link, plain text or encoded WiFi details to your interface. Inspect the report for the format and diagnostics, then choose which action to offer.
Start with a selected File and return its decoded QR text. Choose JavaScript or TypeScript for the same browser package.
Choose a package manager for the browser package on npm. The same MIT-licensed package reads QR codes (including Micro QR and rMQR) and barcodes, and is also served on jsDelivr, unpkg and esm.sh for browser demos without a bundler.
The browser API documents every entry point, including /auto, /scan and /camera, and the licensing guide explains the MIT licence and component notices. To try the scanner before installing anything, open the Vite example in StackBlitz or the Hugging Face Space. The QR Code Scanner examples show what it returns and how to run it on your machine.
npm install @qrcode-ai-com/qrcode-barcode-scanner-wasm
Save the JavaScript or TypeScript version as your reader module and call readQrImage(file) from your file-input flow. Initialisation is reused after success and cleared after rejection so an explicit retry can run.
import init, { scan_image } from "@qrcode-ai-com/qrcode-barcode-scanner-wasm";
const WORK_BUDGET_MS = 1000;
let ready = null;
const prepareScanner = () => {
ready ??= init().catch((error) => {
ready = null;
throw error;
});
return ready;
};
export const readQrImage = async (file) => {
await prepareScanner();
const bytes = new Uint8Array(await file.arrayBuffer());
const report = scan_image(
bytes, "frame", undefined, undefined, WORK_BUDGET_MS
);
return report.detections
.filter((detection) => detection.symbology === "qr_code")
.map((detection) => detection.content.text);
};
The example passes undefined for the two image size limits, as the scanner’s own browser example does, so the engine’s defaults apply: 10,000 px per side and 64,000,000 pixels. An ordinary mobile phone photo, up to 48 megapixels, stays within them. An image above either limit is refused with an input error (QRS-002 or QRS-003): it is not resized. On a server that accepts images from the public, pass lower limits: the scanner’s documentation uses 4,096 px and 16,000,000 pixels. The 1,000 ms work budget is not an end-to-end response-time guarantee.
The second argument, "frame", is the scan profile. The frame profile only decodes; fast and full also compute the 0 to 100 QR score. For named options such as formats: ["qr_code"] and an isFinal flag, the package also provides the /scan entry (bindScanner).
A QR code image that encodes https://qrcode-ai.com/ returns ["https://qrcode-ai.com/"]. Display that string in your interface; opening the link or offering another action remains your app’s choice.
A blank image, or one that holds only other codes such as a barcode, returns an empty array. A file that is not a readable image, or an image above the size limits, makes the call throw instead: catch that error.
Compare browser QR decoders: QR Code AI pairs image and frame scanning with a /camera controller, barcode support and QR quality diagnostics.
| Capability | qr-scanner | ZXing Browser | ||
|---|---|---|---|---|
Image input | Bytes + RGBAThe QR Code AI browser package exposes scan_image for encoded image bytes (PNG, JPEG, WebP or GIF) and scan_frame for RGBA pixels with their dimensions, plus the /scan helper for named options. Your application reads the file or supplies the frame. | RGBA pixelsjsQR accepts a Uint8ClampedArray of RGBA pixels, width and height. Your application decodes a saved image or extracts pixels from a camera frame. | Image sourcesQrScanner.scanImage accepts image, video and canvas elements, ImageBitmap, File/Blob and supported image URLs. Cross-origin image URLs need appropriate CORS access. | Image sourcesThe browser API provides image-element, image-URL and canvas decoding methods. Choose the QR or multi-format reader appropriate to the input. |
Camera controls | Controller + overlayThe /camera and /camera-overlay entries provide a capture controller, a tracker of measured positions and an overlay with a readout of the selected code. Decoding stays in your module Web Worker, and camera access still needs the user’s permission. | App-managedThe jsQR README explicitly leaves platform-specific capture to the application. Its webcam example extracts ImageData before invoking the decoder. | Start / stopFor a camera integration, the documented QrScanner API supplies start(), stop() and destroy() around a video element. This reduces host capture and lifecycle wiring compared with decoder-only APIs; permission is still required. | Capture / stopFor a camera integration, decodeFromVideoDevice and decodeFromConstraints supply capture helpers and controls.stop(). This reduces host capture and lifecycle wiring compared with decoder-only APIs; permission is still required. |
Returned data | Text + payloadThe scan report gives each detection’s symbology (the type of code, such as qr_code), decoded text and raw bytes, recognised structured payloads such as URLs or WiFi settings, and trace information. Returned data never opens a URL or joins a network. | Text + bytesThe documented result contains data, binaryData, chunks, version and location points. These are decoded content and geometry, not a documented scannability grade. | Text + cornersWith the documented detailed-result API, the result contains data and cornerPoints. The older string-only result remains a separate compatibility path in this source revision. | Text + metadataThe decoding result carries text, format, result points and format-dependent metadata. Metadata such as error-correction level is not a QR scannability grade. |
QR diagnostics | full / fastThe full and fast profiles add a 0 to 100 QR score with actionable hints, useful when a workflow needs more than decoded content. The frame profile skips scoring, and a null score means no judgement. The score is a software diagnostic and does not certify printed labels. | Not describedThe jsQR result lists data, binaryData, chunks, version and location. Its documentation describes no QR scannability score or hints. | Not describedThe qr-scanner detailed result describes data and cornerPoints. Its documentation describes no QR scannability score or hints. | Not describedThe ZXing Browser documentation describes no QR scannability score or hints. Format metadata and error-correction information are different data. |
Green ticks mark documented advantages for the stated criterion; plain text is neutral. “Not described” means the cited documentation does not describe the capability. Open underlined labels for details. This table is not a speed or accuracy benchmark.
Sources: QR Code AI browser API, report specification, jsQR, qr-scanner and ZXing Browser.
Camera and Web Workers. Pass RGBA pixels to scan_frame or wire the /camera controller and overlay (see the camera example). Calls are synchronous, so run scans in a module Web Worker off the UI thread; see the browser API.
WASM loading and entry points. Exclude the package from Vite/Nuxt pre-bundling and set worker.format to "es" for /auto in Web Workers. Use root init(), /auto (createScannerLoader(), SSR-safe), /scan (named formats + isFinal) or /node for WASM-in-Node; details in the package setup guide.
Errors and local privacy. No code returns an empty array; catch init() rejections and [QRS-001]/[QRS-002]/[QRS-003] throws. Frame skips scoring (null score is not zero). Once loaded, decoding runs 100% on the user’s device.
These references follow the main branch of the scanner repository.
Browser setup, TypeScript, Web Workers, camera input, decoded data and licensing.
The JavaScript QR Code Scanner SDK is QR Code AI’s open-source MIT browser package for reading QR codes from images and camera frames inside your own web application. It is published on npm as @qrcode-ai-com/qrcode-barcode-scanner-wasm, a WebAssembly build of the QR Code & Barcode Scanner engine, and it decodes on the user’s device. Your application supplies the file or camera input, its interface and the actions that follow a result. The QR Code Scanner SDK page covers other runtimes.
Yes. JavaScript and TypeScript use the same browser package. Its published declarations include scan_image, scan_frame and ScanReport. The TypeScript example adds File and return types around the same decoding API; it does not require a separate TypeScript SDK package.
Yes. scan_image accepts encoded image bytes, while scan_frame accepts RGBA pixels, width and height. The quickstart on this page handles a selected File. For live capture, the /camera entry adds a capture controller and the /camera-overlay entry draws the selection. Your app still requests camera permission and decides when scanning stops.
In your Vite config, add @qrcode-ai-com/qrcode-barcode-scanner-wasm to optimizeDeps.exclude so its WASM URL resolves, and set worker.format to "es" when a module Web Worker imports the /auto entry. The Vite example on the QR Code Scanner examples page sets both. In Nuxt, put the same optimizeDeps.exclude entry under the vite key of your Nuxt config. Importing the /auto entry is safe during server rendering, but load the scanner and construct the Web Worker only in the browser, for example from a client-only component or mounted feature. Verify that the built application serves the .wasm asset under the actual deployment base path.
The WASM scan call is synchronous on the thread that invokes it. A Web Worker moves that decoding work away from the main interface thread. Your app still controls loading, input limits, result messages and disposal. For live capture, wait for a scan to finish before scheduling the next frame; the Web Worker is not an automatic frame-rate or latency guarantee.
Both load the same portable WASM module. The root entry initialises it with init(). The /auto entry exposes loadScanner() and createScannerLoader(), which check WebAssembly features first and report typed loading errors. A loader memoises its single initialisation attempt, including a failure, so create a new loader for an explicit retry. An asset or policy error does not prove a missing browser feature.
The quickstart’s readQrImage(file) returns an empty array, [], when the image holds no QR code. The scan report still lists every code the engine read in report.detections, so an image that holds only a barcode gives a non-empty report and an empty QR result. An empty result is final only when the scan was not cut by its work budget: report.trace.budget_exhausted is then false. A file that is not a readable image, or an image above the size limits, does not return []: the call throws an error whose message ends with its code, [QRS-001] for an unreadable file, [QRS-002] or [QRS-003] for an image above a size limit. A loading failure makes init() reject. Wrap await readQrImage(file) in try/catch, clear the previous value and tell the user whether no QR code was found or the file was refused.
Select a profile based on what the image needs, then by the score. The frame profile is the lightest: it only decodes and skips scoring, so score is null. It suits live camera frames, and the quickstart on this page uses it for a selected image. The fast and full profiles also compute the 0 to 100 QR score and its hints, fast at reduced depth and full at full depth. The full profile is the engine’s default and the only one that runs the deepest pre-processing stage: when frame or fast finds no code in a hard image, such as an artistic QR code, scan it again with full. A null score means no judgement, not zero. A work budget is not an end-to-end response-time guarantee, and the score is a software diagnostic: it does not certify printed labels or the safety of a destination.
Yes. After the package files load, the browser decode path runs on the device without a QR Code AI login or hosted decoding request. Your application determines uploads, analytics, storage and destination requests. Offline operation also requires the application and its WASM file to be delivered and cached; local decoding is not a blanket privacy or offline guarantee.
Yes. Current releases of the browser SDK are published under the MIT licence, which permits use, modification and redistribution in both open-source and proprietary commercial applications while preserving the copyright and licence notices. Review the licensing guide for retained third-party notices and the terms shipped with earlier versions.
No. Local browser decoding does not require a QR Code AI generation API key or consume QR creation credits. SDK licensing is separate from the creation platform. On that platform, free creation limits and Premium apply to creation features, not to decoding; the seven-day Premium trial starts with the first dynamic QR code or Smart Link. Directly encoded data does not expire after that trial, although a managed destination can become unavailable. Decoding cannot restore that destination.
Yes for barcodes, no for native Node.js. The same browser package, @qrcode-ai-com/qrcode-barcode-scanner-wasm, reads QR codes and barcodes: the JavaScript Barcode Scanner SDK uses it too. The example on this page keeps only the detections whose symbology is qr_code. For server-side Node.js with native performance, use @qrcode-ai-com/qrcode-barcode-scanner (or use this package’s /node entry when native addons cannot run). Visit the QR Code Scanner SDK page to choose another environment.