JavaScript QR Code Scanner SDK

Build QR code scanning straight into your web app. Decode text from uploaded images or live camera frames directly inside the browser, keep your own UI and control what happens after every scan.

JavaScript
import init, { scan_image } from
  "@qrcode-ai-com/qrcode-barcode-scanner-wasm";

await init();
const bytes = new Uint8Array(await file.arrayBuffer());
const report = scan_image(
  bytes, "frame", undefined, undefined, 1000
);
const qr = report.detections
  .find(d => d.symbology === "qr_code");

console.log(qr?.content.text);

Inspect the decoded resulthttps://qrcode-ai.com/

Read a QR image

Allow users to pick a screenshot, saved image or mobile photo of a QR code. Receive the decoded text so your UI can render it or pass it onwards.

npm install @qrcode-ai-com/qrcode-barcode-scanner-wasm

Need to scan a QR code right away? Open the online reader

Bring QR scanning into your web app

Let users upload an image, scan through your own camera view and act on the decoded text without leaving your app.

Read a QR image

Allow users to pick a screenshot, saved image or mobile photo of a QR code. Receive the decoded text so your UI can render it or pass it onwards.

Read a camera frame

Feed captured RGBA pixels to scan_frame, or wire up the package’s /camera controller and overlay while your app handles permissions.

Use the decoded content

Send a link, plain text or encoded WiFi credentials back to your UI. Check the report for symbology and diagnostics, then decide which action to show.

Add QR image scanning in JavaScript or TypeScript

Take a selected File and return its decoded QR text. Pick either JavaScript or TypeScript for the exact same browser package.

Install the browser package

Pick your preferred package manager for the browser package on npm. The same MIT-licensed package decodes QR codes (including Micro QR and rMQR) as well as barcodes, and is also available on jsDelivr, unpkg and esm.sh for quick browser prototypes without a bundler.

The browser API covers every entry point, including /auto, /scan and /camera, while the licensing guide details the MIT licence and third-party notices. To test the engine before installing anything locally, launch the Vite example in StackBlitz or open the Hugging Face Space. The QR Code Scanner examples illustrate sample outputs and local setup steps.

npm install @qrcode-ai-com/qrcode-barcode-scanner-wasm

Read a QR image

Save either the JavaScript or TypeScript snippet as your reader module and invoke readQrImage(file) inside your file-input handler. Initialisation is cached once it succeeds and reset if it rejects so an explicit retry can run cleanly.

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);
};

This snippet passes undefined for both image size caps, matching the scanner’s own browser example, so the engine defaults apply: 10,000 px per side and 64,000,000 pixels in total. A standard mobile phone photo up to 48 megapixels fits comfortably within those bounds. Any image exceeding either cap is rejected with an input error (QRS-002 or QRS-003) instead of being resized. For a backend accepting public uploads, supply tighter limits: the scanner documentation uses 4,096 px and 16,000,000 pixels. The 1,000 ms work budget is a cap, not an end-to-end latency guarantee.

The second parameter, "frame", selects the scan profile. The frame profile decodes only; fast and full additionally compute the 0 to 100 QR score. When you want named options such as formats: ["qr_code"] along with an isFinal flag, import the /scan entry (bindScanner).

Inspect the decoded result

A QR code image encoding https://qrcode-ai.com/ returns ["https://qrcode-ai.com/"]. Show that value in your interface; opening the URL or triggering another workflow stays entirely under your app’s control.

A blank image, or one containing only non-QR symbols such as a barcode, returns an empty array. An unreadable file or an image exceeding the dimension limits causes the call to throw instead, so wrap it in try/catch.

Compare JavaScript QR scanner APIs

Compare browser QR libraries: QR Code AI combines image and frame decoding with a /camera controller, barcode support and QR quality diagnostics.

Browser APIs · sources listed below · QR Code AI column updated 27 November 2026
CapabilityQR Code AIWASM · MITjsQRjsqrqr-scannerNimiqZXing Browser@zxing/browser

Image input

RGBA pixels

jsQR expects a Uint8ClampedArray of RGBA pixels along with width and height. Your app handles decoding saved image files or pulling pixels from a camera feed.

Image sources

QrScanner.scanImage works with image, video and canvas elements, ImageBitmap, File or Blob objects and supported image URLs. Cross-origin URLs require valid CORS headers.

Image sources

The browser layer offers image-element, image-URL and canvas decoding methods. Pick either the QR-only reader or the multi-format reader depending on your input.

Camera controls

App-managed

The jsQR README leaves device-specific camera capture to your application. Its webcam snippet extracts ImageData from a canvas before passing pixels to the decoder.

Start / stop

For camera scanning, the documented QrScanner API exposes start(), stop() and destroy() around a video element. That trims capture lifecycle code compared with decoder-only libraries, though user permission is still mandatory.

Capture / stop

For live video scanning, decodeFromVideoDevice and decodeFromConstraints provide capture helpers alongside controls.stop(). That reduces host capture wiring compared with decoder-only APIs; user permission is still required.

Returned data

Text + bytes

The documented return object carries data, binaryData, chunks, version and location coordinates. Those describe decoded content and geometry rather than a scannability grade.

Text + corners

With the documented detailed-result API, results include data and cornerPoints. The older plain-string return format remains a separate compatibility mode in this revision.

Text + metadata

Decoded results provide text, format, result points and format-specific metadata. Metadata such as the error-correction level is distinct from a QR scannability grade.

QR diagnostics

Not described

The jsQR result documents data, binaryData, chunks, version and location. Its README does not describe a QR scannability score or improvement hints.

Not described

The qr-scanner detailed result lists data and cornerPoints. Its documentation does not describe a QR scannability score or diagnostic hints.

Not described

The ZXing Browser documentation does not describe a QR scannability score or improvement hints. Format metadata and error-correction fields serve a different purpose.

Green ticks indicate documented advantages for the stated criterion; plain text is neutral. “Not described” means the cited documentation does not mention the capability. Select underlined labels for full details. This comparison is not a speed or accuracy benchmark.

Sources: QR Code AI browser API, report specification, jsQR, qr-scanner and ZXing Browser.

Build around your browser workflow

Camera and Web Workers. Supply RGBA pixels to scan_frame or integrate the /camera controller and overlay (see the camera example). Because decode calls are synchronous, run them inside a module Worker off the UI thread; refer to the browser API.

WASM loading and entry points. Exclude the package from Vite or Nuxt pre-bundling and configure worker.format as "es" when using /auto inside Workers. Pick root init(), /auto (createScannerLoader(), SSR-safe), /scan (named formats + isFinal) or /node for WASM-in-Node; full steps are in the package setup guide.

Errors and local privacy. When no code is present, an empty array is returned; catch init() rejections alongside [QRS-001]/[QRS-002]/[QRS-003] throws. The frame profile skips scoring (a null score is unmeasured, not zero). Once loaded, all decoding stays 100% on the user’s device.

QR Code Scanner browser API, reports and licensing

These technical references track the main branch of the scanner repository.

JavaScript QR scanner questions

Browser setup, TypeScript, Web Workers, camera capture, decoded output and licensing.

The JavaScript QR Code Scanner SDK is QR Code AI’s open-source MIT-licensed browser package for decoding QR codes from images and live camera frames inside your own web app. Published on npm as @qrcode-ai-com/qrcode-barcode-scanner-wasm, it ships a WebAssembly build of the QR Code & Barcode Scanner engine that runs locally on the user’s device. Your app controls file or camera input, the UI and any follow-up action. See the QR Code Scanner SDK page for other runtimes.

Yes. Both JavaScript and TypeScript use the exact same browser npm package. Its bundled type declarations cover scan_image, scan_frame and ScanReport, so the TypeScript snippet simply adds File and return annotations around the same decoding calls without requiring a separate types package.

Yes. Use scan_image for encoded image bytes and scan_frame for raw RGBA pixels with width and height. The quickstart above reads an uploaded File, while the /camera entry provides a live capture controller and /camera-overlay renders the selection box. Your web app still handles webcam or mobile camera permission prompts and decides when to stop scanning.

In your Vite config, add @qrcode-ai-com/qrcode-barcode-scanner-wasm to optimizeDeps.exclude so its WASM asset URL resolves properly, and set worker.format to "es" whenever a module Worker imports the /auto entry. The Vite demo on the QR Code Scanner examples page configures both options. In Nuxt, place that optimizeDeps.exclude entry under the vite key in nuxt.config. Importing /auto is SSR-safe, but instantiate the Worker and load the scanner strictly on the client, such as inside a client-only component or onMounted hook, and verify that production builds serve the .wasm file under your deployment base path.

Each WASM decode call executes synchronously on the thread that calls it. Running it inside a Web Worker keeps heavy decoding off the main UI thread so scrolling and taps remain smooth. Your app still manages initialisation, input size caps, message passing and teardown. For live camera feeds, wait for the active scan to finish before queuing the next frame, because a Worker alone does not guarantee frame rate or latency.

Both paths load the same portable WASM binary. Importing from the package root lets you initialise it manually with init(). Importing from /auto gives you loadScanner() and createScannerLoader(), which verify WebAssembly capabilities up front and surface typed loader errors. A loader memoises its single initialisation attempt, even on failure, so create a fresh loader instance for an explicit retry. Keep in mind that a blocked asset or browser policy error does not prove the browser lacks WebAssembly support.

The quickstart’s readQrImage(file) returns an empty array, [], whenever no QR code is detected in the image. Every symbol the engine read still appears in report.detections, so a barcode-only image yields a populated report alongside an empty QR list. Treat an empty result as final only when the work budget was not exhausted, meaning report.trace.budget_exhausted is false. Unreadable files or oversized images throw instead of returning []: the error message ends with [QRS-001] for unreadable files and [QRS-002] or [QRS-003] for dimension or pixel-count caps, while load failures reject init(). Wrap await readQrImage(file) in try/catch, reset any previous result and inform the user clearly.

Pick a profile based on image difficulty first and scoring needs second. The frame profile is the lightest option because it decodes without computing a score, leaving score as null; it fits live camera frames and powers the file quickstart on this page. The fast and full profiles also compute a 0 to 100 QR score with hints, with fast running at reduced depth and full at full depth. Because full is the default and only profile with the deepest preprocessing stage, retry with full whenever frame or fast misses a tricky or artistic QR code. Remember that 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 rather than print certification or destination-safety verification.

Yes. Once the browser fetches the package assets, all decoding runs locally on the user’s device without a QR Code AI account or any hosted decoding API call. Your own code governs uploads, analytics, persistence and outbound link requests. Full offline usage also requires your app to bundle and cache both its pages and the .wasm asset; local execution alone is not an automatic privacy or offline guarantee.

Yes. Current releases of the browser SDK ship under the MIT licence, allowing use, modification and redistribution in both open-source and proprietary commercial web apps as long as copyright and licence notices are preserved. Check the licensing guide for retained third-party notices and the terms that applied to earlier releases.

No. Local browser QR decoding never needs a QR Code AI generation API key and never deducts creation credits. SDK licensing is completely separate from the QR creation platform. On that platform, free limits and Premium plans govern creation features rather than scanning, and the seven-day Premium trial begins with your first dynamic QR code or Smart Link. Directly encoded data does not expire after the trial, though a managed destination can stop resolving, and a scanner cannot recover an expired destination.

It handles barcodes in the browser, but native Node.js servers use a separate package. @qrcode-ai-com/qrcode-barcode-scanner-wasm reads both QR codes and barcodes and also powers the JavaScript Barcode Scanner SDK; the quickstart here simply filters detections down to qr_code. For server-side Node.js with native speed, install @qrcode-ai-com/qrcode-barcode-scanner (or import this package’s /node entry when native addons cannot run). Visit the QR Code Scanner SDK hub to pick another runtime.