Browser example
An interactive web page that decodes images locally in your browser. Launches directly in StackBlitz with no account.
Open in StackBlitzWASM + Python
StackBlitz, Binder, Colab
QR code + Code 128
MIT
Explore hosted browser demos, standalone Vite or Jupyter starters, or the ready-made examples bundled with the browser SDK and CLI.
Links verified on 27 November 2026. The StackBlitz, Binder and Google Colab links target a pinned release tag in the scanner repository so they continue running identical files; the GitHub Pages demo and Hugging Face Space track the published release.
Both the browser demo and Python notebook start from a fresh clone of the scanner repository. If you already have a local copy, omit git clone and run the notebook steps from the repo root. Each starter installs an exact pinned package version.
Requires Node.js 20.19+ or 22.12+. The folder is self-contained: npm ci installs exact lockfile dependencies and npm run dev starts the local server. Open the URL Vite prints in your browser.
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
Run npm run build to output static assets into dist/, and npm run preview to test the built folder.
Requires Python 3 with the venv module. The first install step enforces file hashes for every package, so JupyterLab is installed in a separate command. Once open, pick Run All inside the notebook.
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\.
These snippets are extracted directly from the two starters. In JavaScript, a module Worker initialises the scanner once and invokes scan_image on the chosen image bytes. In Python, scan receives the image bytes plus a profile controlling analysis depth. Both set the time budget to 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 excerpt forms a single notebook cell. Previous cells import qrcode_barcode_scanner as scanner and read the sample image bytes into sample.
Trigger Run All to execute every cell. The seven lines below come from the notebook’s output. The opening three lines list detections across fast, frame and full profiles, each finding the same two codes (sorted by type so code128 appears before qr_code). The fourth line shows the 0 to 100 scannability score computed under full for the first code in the report, which is the QR code since QR detections sort first.
Additional cells print environment checks beforehand: Python version, OS platform, installed package version, SHA-256 hash of the module and the PyPI wheel filename. After the score, another cell prints four detail 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” along with the four detected corner coordinates.
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 correspond to the blank image, the non-image file and the last cell waiting for your custom image path.
A dedicated Worker runs the scanner. The web page transfers the chosen image bytes to a module Worker, which initialises the library once via createScannerLoader from the /auto entrypoint and calls scan_image.
Smooth UI and local processing. Because decoding executes inside the Worker, the page stays responsive throughout the scan and image data never leaves your device.
Required Vite options. Listing the package under optimizeDeps.exclude ensures its modules locate the adjacent .wasm binary correctly, while worker.format set to es satisfies the /auto loader.
Combined sample payload. The test image holds one QR code (https://qrc-ai.com/76xMa) alongside one Code 128 barcode (STOCK-4827). Every profile (fast, frame and full) returns both detections with symbology, payload.kind and content.text.
Quality scoring and safety. The frame profile skips scoring, whereas fast and full attach a 0 to 100 scannability score to the first detection. Decoded URLs remain plain strings and are never launched automatically.
Empty scans and invalid files. An image containing no symbol returns an empty array instead of throwing. Corrupted or non-image inputs raise QRS-001 (Error in JavaScript and ValueError in Python).
Verify the sample image first, test one of your own files, then drop the scanning snippet into your project.
Launch a demo online or locally and run the sample file. Confirm that it returns the URL https://qrc-ai.com/76xMa.
Upload a file in the Vite page or update the path in the final notebook cell. Inspect the returned text and payload kind.
Reuse the Worker setup or Python scan lines, keep the dependency pinned in your lockfile and open your language SDK guide.
These documentation links track the main branch of the scanner repository.
Online demos, sample output, custom files, empty scans and code reuse.
The QR Code Scanner examples are self-contained starter projects built on the official packages of QR Code & Barcode Scanner, QR Code AI’s open-source MIT library: a Vite web app (available on StackBlitz, GitHub Pages and Hugging Face Spaces) and a Python Jupyter notebook (available on Binder and Google Colab). Every project installs a pinned published release and decodes a sample image so you can verify output before writing code. Both also run locally from the examples folder in the public repository.
No sign-up is needed for StackBlitz, GitHub Pages, Hugging Face Spaces or Binder. StackBlitz boots the Vite project inside your browser, GitHub Pages hosts the static build directly and Binder spins up an ephemeral Python environment (taking a couple of minutes to start and timing out after roughly ten minutes of inactivity). Google Colab runs the exact same notebook but requires signing in with a Google account.
Pick the browser demo first if you are building a website or web app: it demonstrates Worker-based WebAssembly decoding where images stay strictly on the user’s device. Pick the Python notebook if you work in Python or prefer inspecting results cell by cell. For shell scripts or CI pipelines, go straight to the QR Code Scanner CLI.
The bundled sample image contains one QR code and one Code 128 barcode. Scanning returns both detections: the QR code carrying https://qrc-ai.com/76xMa and the Code 128 barcode holding STOCK-4827. All three profiles (fast, frame and full) detect the exact same pair, while fast and full also score how cleanly the first symbol scans.
Pinning to a specific release tag ensures bookmarked demo links keep loading the exact same files even as the main branch changes. Each StackBlitz, Binder and Google Colab starter also pins its scanner dependency via a lockfile or SHA hashes so every launch installs identical bytes.
Not in the browser demo: the decoder runs locally via WebAssembly inside a browser Worker, so your image never leaves your device. The notebook likewise decodes inside its Python process without forwarding images elsewhere. Locally, that process stays on your computer; on Binder or Google Colab, the session runs on remote servers, so only upload test files you are comfortable sharing with those hosts.
If an image contains no readable code, the scanner returns an empty list rather than throwing an error, and the browser page notes that nothing was detected. If the image contains a different symbology, such as the sample’s Code 128 barcode, it is included in the array, so filter for symbology equal to qr_code when you want QR codes alone. Non-image files are handled separately: the library rejects them with error code QRS-001, and Python raises ValueError. Both starters include empty and invalid test inputs to demonstrate separate handling.
Yes. Both the example projects and current scanner packages ship under the MIT licence, letting you copy, customise and deploy them inside open-source or commercial software as long as you retain copyright and licence notices. Check the licensing guide for included third-party notices.
No. Decoding an existing image is completely independent of the QR Code AI creation service and its generation API. The creation service has free creation limits, a seven-day Premium trial triggered when you create your first dynamic QR code or Smart Link, and Premium requirements for ongoing use of affected features. Reading a code does not start that trial, and directly encoded content stays unchanged in the symbol. The scanner itself is open source under the MIT licence.