QR Code Scanner Examples

Test the open-source QR Code & Barcode Scanner library before writing any code. Launch a browser demo or Python notebook online, scan the sample image and inspect the decoded link.

Browser example

An interactive web page that decodes images locally in your browser via StackBlitz, with no account needed.

Open in StackBlitz

Python notebook

A Jupyter notebook that installs the Python package and checks every result on Binder, with no account needed.

Launch on Binder

Source code

Browse both runnable examples and setup instructions inside the public scanner repository.

View examples on GitHub

QR Code Scanner examples at a glance

  • Published packages, version-pinned

    WASM + Python

  • Hosted demos & notebooks

    StackBlitz, Binder, Colab

  • Codes in the sample image

    QR code + Code 128

  • Open-source licence

    MIT

Pick a QR code scanner example

Explore hosted browser demos, runnable Vite or Jupyter projects, or the zero-bundler examples shipped with the browser SDK and CLI.

What it shows
Install the wheel, verify what is installed, scan the sample across all three profiles (fast, frame and full, representing three analysis depths), then inspect each code’s type, decoded text, payload kind (link, plain text) and coordinates.
Package
qrcode-barcode-scanner on PyPI
Run online
Launch on Binder without an account (startup takes a few minutes and expires after roughly ten minutes idle), or open the Google Colab notebook using a signed-in Google account.
Launch notebook on Binder

What it shows
One page decodes a selected image inside a module Worker. Another reads from the camera using the package’s camera controller, tracker and live overlay.
How to run
Install the npm package and serve its folder with any static HTTP server. No bundler or framework is required.
Read package examples

What it shows
Decode a saved image file and inspect the JSON report, with distinct exit codes separating detections, empty scans and invalid inputs.
Runs on
macOS, Linux and Windows.
Open CLI guide

Links verified on 27 November 2026. The StackBlitz, Binder and Google Colab links target a pinned release tag so they continue running identical files; the GitHub Pages demo and Hugging Face Space track the published release.

Run the QR code examples locally

Both the Vite browser app and the Python notebook start from a fresh clone of the scanner repository. If you already have a local copy, skip git clone and execute the notebook steps from the repo root. Both projects pin exact published package versions.

Run the browser example

Requires Node.js 20.19+ or 22.12+. The folder is self-contained: npm ci installs exact dependencies from its lockfile and npm run dev launches the dev server. Open the local URL Vite prints.

Shell
git clone https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust.git
cd qrcode-barcode-scanner-rust/examples/web-vite
npm ci
npm run dev

npm run build outputs the static site to dist/, and npm run preview serves that build.

Run the Python notebook

Requires Python 3 with the venv module. Because the initial install verifies package hashes, JupyterLab is installed in a separate command. Once open, select Run All.

Shell
git clone https://github.com/qrcode-ai-com/qrcode-barcode-scanner-rust.git
cd qrcode-barcode-scanner-rust
python3 -m venv .venv
.venv/bin/python -m pip install -r binder/requirements.txt
.venv/bin/python -m pip install jupyterlab
.venv/bin/jupyter lab examples/notebooks/scan-images.ipynb

On Windows, look for the executables inside .venv\Scripts\.

Core scanning calls

These snippets come directly from both examples. In the browser, a module Worker initialises the scanner once and invokes scan_image on the file bytes. In Python, scan takes the image bytes plus a profile controlling analysis depth. Both pass a budget of 0 so every scan runs to completion.

// A module worker that owns one scanner. The page posts { id, type: 'load' } once, then
// { id, type: 'scan', bytes, profile } for each image, and gets one reply with the same id:
//   { id, ok: true, version, variant }             after 'load'
//   { id, ok: true, report, ms }                   after 'scan'
//   { id, ok: false, phase, error }                phase: 'load' or 'scan'
// Scanning in a worker keeps the page responsive while an image is decoded.
import { createScannerLoader } from '@qrcode-ai-com/qrcode-barcode-scanner-wasm/auto';

// One loader for the life of this worker. It fetches and compiles the WebAssembly module once.
const load = createScannerLoader();

// 0 removes the time budget: every scan runs to its end.
const BUDGET_MS = 0;

function describe(error) {
  const message = error && error.message !== undefined ? String(error.message) : String(error);
  const qrs = /\[(QRS-\d{3})\]/.exec(message);
  return {
    name: error && error.name ? String(error.name) : 'Error',
    message,
    // A loading failure carries a stable code; a refused input ends with [QRS-xxx].
    code: error && typeof error.code === 'string' ? error.code : null,
    qrs: qrs ? qrs[1] : null,
  };
}

self.onmessage = async ({ data }) => {
  const { id, type } = data;
  let phase = 'load';
  try {
    const scanner = await load();
    if (type === 'load') {
      self.postMessage({ id, ok: true, version: scanner.version(), variant: scanner.variant });
      return;
    }
    phase = 'scan';
    const started = performance.now();
    const report = scanner.scan_image(new Uint8Array(data.bytes), data.profile, undefined,
      undefined, BUDGET_MS);
    self.postMessage({ id, ok: true, report, ms: performance.now() - started });
  } catch (error) {
    self.postMessage({ id, ok: false, phase, error: describe(error) });
  }
};

The Python snippet is a single notebook cell. Earlier cells import qrcode_barcode_scanner as scanner and read the sample image bytes into sample.

Sample notebook output

Select Run All to see these seven key output lines. The first three show detections under fast, frame and full: every profile returns the same two codes (sorted alphabetically by type, placing code128 ahead of qr_code). The fourth shows the 0 to 100 scannability score computed by full for the first code in the report, which is the QR code because reports always order QR codes first.

Earlier cells also display your Python version, OS platform, package version, SHA-256 digest of the installed module and PyPI wheel filename. After the score, another cell prints four lines per code: for the QR code, its symbology (qr_code), decoded URL (https://qrc-ai.com/76xMa), payload kind (url) and “measured as quad” with its four detected corner points.

Text
fast  code128: STOCK-4827 · qr_code: https://qrc-ai.com/76xMa
frame code128: STOCK-4827 · qr_code: https://qrc-ai.com/76xMa
full  code128: STOCK-4827 · qr_code: https://qrc-ai.com/76xMa
Scannability of the first code: 100 out of 100, excellent
White image: no code found, and the scan finished.
Not an image: unsupported or corrupt image: The image format could not be determined [QRS-001]
Set MY_IMAGE to the path of an image, then run this cell again.

The final three lines demonstrate an image without codes, a rejected non-image file and the last cell waiting for your own image path.

How the browser demo decodes a QR code

A Worker owns the scanner. The page passes the selected image’s bytes to a module Worker, which loads the WASM engine once via createScannerLoader from the /auto entry and calls scan_image.

Smooth UI and local processing. Decoding runs off the main thread inside the Worker so the interface stays responsive and your image never leaves your device.

Two Vite settings. optimizeDeps.exclude lists the package so its modules locate the adjacent .wasm binary, while worker.format is set to es as required by the /auto loader.

What a QR code scan returns

Mixed sample output. The bundled sample contains one QR code (https://qrc-ai.com/76xMa) and one Code 128 barcode (STOCK-4827). Fast, frame and full each return both with symbology, payload.kind and content.text.

Scoring and safety. The frame profile decodes without scoring, while fast and full add a 0 to 100 score for the first detection. Decoded URLs stay plain text and are never visited automatically.

Empty scans and invalid files. An image containing no code returns an empty list rather than throwing. Non-image files fail with QRS-001 (Error in JavaScript, ValueError in Python).

Move from a demo to QR code scanning in your project

Test with the sample image, verify your own file, then lift the scanning calls into your codebase.

  1. Step 1

    Scan the bundled sample

    Launch a demo online or locally and scan the sample image to confirm it returns https://qrc-ai.com/76xMa.

  2. Step 2

    Test your own image

    Select a file in the browser app or supply its path in the final notebook cell, then inspect content.text and payload.kind.

  3. Step 3

    Copy the call into your app

    Reuse the Worker or scan calls, keep the package version pinned in your lockfile and follow your language SDK guide.

QR Code Scanner APIs and licence

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

QR Code Scanner examples questions

Online demos, sample output, local privacy, empty scans and code reuse.

The QR Code Scanner examples are self-contained starter projects running the published packages of QR Code & Barcode Scanner, QR Code AI’s open-source MIT library: a Vite browser page (hosted on StackBlitz, GitHub Pages and Hugging Face Spaces) and a Python Jupyter notebook (hosted on Binder and Google Colab). Each pins a published release and decodes a sample image so you can inspect real output immediately. Both also run locally from the repository examples directory.

No account is required for StackBlitz, GitHub Pages, Hugging Face Spaces or Binder. StackBlitz runs the Vite app right in your browser, GitHub Pages serves the compiled static site directly and Binder spins up a temporary Python session (taking a few minutes to start and timing out after roughly ten minutes idle). Google Colab runs the same notebook but requires signing in with a Google account.

Start with the browser example if you are building a web app: it shows local WASM decoding inside a module Worker so images stay on-device. Pick the notebook if you prefer Python or want step-by-step inspection. For shell scripts or CI pipelines, use the QR Code Scanner CLI instead.

The bundled sample holds one QR code and one Code 128 barcode, so a scan returns both: the QR code carrying https://qrc-ai.com/76xMa and the Code 128 barcode carrying STOCK-4827. All three profiles (fast, frame and full) detect the exact same two codes, while fast and full also score the first detection.

Pinning a release tag ensures bookmarked demos keep running the exact same files even as the main branch moves forward. StackBlitz, Binder and Google Colab point to that release tag, and each starter locks its scanner package with a lockfile or file hashes so every launch installs identical bytes.

Not in the browser example: WebAssembly runs inside a local Worker in your browser, so images never leave your device. The notebook decodes inside its Python runtime without forwarding images elsewhere. Locally that session stays on your machine; on Binder or Google Colab it runs on the host’s servers, so only upload images you are comfortable sharing there.

When no readable code exists in the image, the scanner returns an empty list, which is a valid result rather than an error, and the browser demo states that no code was found. If the image holds another symbology such as Code 128, filter detections where symbology equals qr_code. A non-image file is rejected with error QRS-001 (raising ValueError in Python). Both demos include empty-image and invalid-file tests.

Yes. Current scanner packages and starter examples are published under the MIT licence, allowing you to copy, adapt and ship them in open-source or commercial software while retaining copyright and licence notices. Check the open-source licensing guide for retained third-party notices.

No. Testing the demos and decoding existing images stays separate from QR Code AI’s creation platform and generation API. That service has free creation limits, a seven-day Premium trial triggered by the first dynamic QR code or Smart Link, and Premium requirements for continued use of affected features. Reading a code triggers no trial and directly encoded data stays intact inside the symbol. The scanner is open source under the MIT licence.