Browser example
An interactive web page that decodes barcode images locally in your browser via StackBlitz, with no account needed.
Open in StackBlitzWASM + Python
StackBlitz, Binder, Colab
Code 128 + QR code
MIT
Explore hosted browser demos, runnable Vite or Jupyter projects, or the zero-bundler examples shipped with the browser SDK and CLI.
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.
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.
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.
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.
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.
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 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.
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, here 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 barcode, its symbology (code128), decoded string (STOCK-4827), payload kind (text for plain text) and “measured as segment” with two endpoints along the scan line.
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.
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 label 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.
Mixed sample output. The bundled sample contains one Code 128 barcode (STOCK-4827) and one QR code (https://qrc-ai.com/76xMa). Every detection includes symbology and content.text; keep leading zeros intact and query products separately.
Symbology mapping and scoring. The symbology field identifies the printed format (GS1-128 → code128, ITF-14 → itf, ISBN → ean13). Frame skips scoring; fast and full score the first code without certifying label print quality.
Empty scans and invalid files. An image containing no code returns an empty list. Non-image files fail with QRS-001 (Error in JavaScript, ValueError in Python).
Test with the sample image, verify your own label, then lift the scanning calls into your codebase.
Launch a demo online or locally and scan the sample image to confirm it returns STOCK-4827 as Code 128.
Select a file in the browser app or supply its path in the final notebook cell, then inspect content.text and payload.kind.
Reuse the Worker or scan calls, keep the package version pinned in your lockfile and follow your language SDK guide.
These technical references track the main branch of the scanner repository.
Online demos, sample output, supported formats, local privacy and reuse.
The Barcode 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 label 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 Barcode Scanner CLI instead.
The bundled sample holds one Code 128 barcode and one QR code, so a scan returns both: the Code 128 carrying STOCK-4827 and the QR code carrying https://qrc-ai.com/76xMa. All three profiles (fast, frame and full) detect the exact same two codes, and each entry includes its symbology so your app can filter strictly for barcodes.
You can test every symbology the engine supports: retail formats EAN-13, EAN-8, UPC-A and UPC-E; linear formats Code 128, Code 39, Code 93, Codabar, ITF, Telepen, GS1 DataBar and GS1 DataBar Expanded; plus 2D formats Data Matrix, PDF417, Aztec and MaxiCode. The bundled sample tests Code 128; select your own label in the browser app or set its path in the notebook for any other format.
Not in the browser example: WebAssembly runs inside a local Worker in your browser, so label 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 labels you are comfortable sharing there.
When no readable code exists in the image, the scanner returns an empty list, which is a valid outcome rather than an error, and the browser demo states that no code was found. If an image contains only a QR code, that QR entry is returned, so inspect each detection’s symbology before treating it as a barcode. Non-image files fail 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 labels 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.