Browser example
A web page that scans images in your browser. It opens in StackBlitz, with no account.
Open in StackBlitzWASM + Python
StackBlitz, Binder, Colab
Code 128 + QR code
MIT
Try hosted browser demos, runnable Vite or Jupyter projects, or the examples shipped with the browser SDK and CLI.
Links verified on November 27, 2026. The StackBlitz, Binder and Google Colab links open a pinned release tag of the scanner repository so they keep running the same files; the GitHub Pages demo and Hugging Face Space reflect the published release.
The browser example and the notebook each start from a fresh clone of the scanner repository. If you already cloned it, skip the git clone line and run the notebook commands from the repository root. Both examples install the published package at an exact pinned version.
You need Node.js 20.19 or later, or 22.12 or later. The folder stands alone: npm ci installs it from its lockfile and npm run dev starts the page. Open the address 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 writes the static page to dist/, and npm run preview serves that folder.
You need Python 3 with its venv module. The first install checks the hash of each package file, so JupyterLab is installed by a second command. Then choose Run All in 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, the commands are under .venv\Scripts\.
These lines come from the two examples. In the browser, a module Worker loads the scanner once and calls scan_image on the bytes of the chosen image. In Python, scan takes the bytes and a profile, the setting that tells a scan how much analysis to run. Both pass a time budget of 0, so every scan runs to its end.
// 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 lines are one cell of the notebook. Earlier cells import the module qrcode_barcode_scanner as scanner and load the bytes of the sample image into sample.
Choose Run All. Among the lines the notebook prints are the seven below. The first three give the codes found with the fast, frame and full profiles: each profile returns the same two codes (the cell sorts them by type, so code128 is printed before qr_code). The fourth is the scannability score, from 0 to 100, that the full profile computes for the first code of the report: here the QR code, because a report lists QR codes first.
The notebook prints more than this excerpt. Before the scans, one cell prints the Python version and platform, the package version, the SHA-256 of the installed module and the name of its PyPI wheel. After the score, another lists each code of the report on four lines: for the barcode, its type (code128), its decoded text (STOCK-4827), its kind of payload (text, which means plain text) and “measured as segment” with two points 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 last three lines are the image without a code, the file that is not an image, and the final cell, which waits for the path of your own image.
A Worker owns the scanner. The page sends the bytes of the chosen image to a module Worker. The Worker loads the scanner once, with createScannerLoader from the package’s /auto entry, then calls scan_image.
The page stays responsive. Decoding runs in the Worker, so the interface keeps responding while an image is scanned, and the image stays on your device.
Two Vite settings. optimizeDeps.exclude names the package, because its modules find the .wasm file next to themselves. worker.format is set to es, which the /auto loader needs.
Mixed sample output. The sample image holds one Code 128 barcode (STOCK-4827) and one QR code (https://qrc-ai.com/76xMa). Each detection reports symbology and content.text; preserve leading zeros and look up products separately.
Format mapping and scoring. Symbology names the printed format (GS1-128 → code128, ITF-14 → itf, ISBN → ean13). Frame skips scoring; fast and full score the first code without certifying print quality.
Empty scans and input errors. An image with no code returns an empty list. Non-image files fail with QRS-001 (Error in JavaScript, ValueError in Python).
Run it once with the sample, try your own image, then move the call into your code.
Open an example online or on your machine and scan the sample. You should get the value STOCK-4827, read as Code 128.
Choose a file in the browser page, or set its path in the last cell of the notebook. Check the decoded text and the kind of payload.
Copy the Worker or the scan lines, keep the package pinned in your lockfile, then follow the guide for your language.
These references follow the main branch of the scanner repository.
Running online, the sample image, your own images, empty results and reuse.
The Barcode Scanner examples are standalone projects that run the published packages of the QR Code & Barcode Scanner, the open-source MIT library from QR Code AI: a browser page built with Vite (hosted on StackBlitz, GitHub Pages and Hugging Face Spaces) and a Jupyter notebook in Python (hosted on Binder and Google Colab). Each one installs a pinned published package and scans a sample image so you see a real result before writing code. Both also run on your machine from the examples folder of the public repository.
No for StackBlitz, GitHub Pages, Hugging Face Spaces and Binder. StackBlitz installs and runs the Vite project in your browser, GitHub Pages serves the compiled web page directly, and Binder builds a temporary Python session (which can take a few minutes and ends after about ten minutes of inactivity). Google Colab runs the same Python notebook but requires a signed-in Google account.
Start with the browser example if you build a web page or a web app: it shows the scanner running in a Worker, with the image staying on your device. Start with the notebook if you work in Python or want to check images step by step. For a terminal or a CI job, use the Barcode Scanner CLI instead.
The sample holds one Code 128 barcode and one QR code. A scan returns both: the Code 128 with the value STOCK-4827 and the QR code with the link https://qrc-ai.com/76xMa. The fast, frame and full profiles give the same two codes. Each result names its format, so your code can keep the barcodes and ignore the rest.
Any format the scanner reads. That covers the retail codes EAN-13, EAN-8, UPC-A and UPC-E, the linear codes Code 128, Code 39, Code 93, Codabar, ITF and Telepen, GS1 DataBar and GS1 DataBar Expanded, and the 2D codes Data Matrix, PDF417, Aztec and MaxiCode. The sample image tests Code 128. For another format, choose your own image in the browser page or set its path in the notebook.
Not in the browser example: the scanner runs as WebAssembly in a Worker of your own browser, so the image stays on your device. The notebook decodes an image inside its Python session and sends it nowhere else. On your machine that session is local. On Binder or Google Colab it runs on the host’s servers, so an image you add there is uploaded to that host: add only images you may share.
The scan returns the codes it found, and an empty list when there is none. An empty list is a valid result, not an error, and the browser example reports that no code was found. An image that holds only a QR code returns that QR code, so check the symbology of each result before you treat it as a barcode. A file that is not an image is a different case: the scanner refuses it with the input error QRS-001, and the Python package raises ValueError. Both examples include the empty image and the refused file.
Yes. The examples and current scanner packages are published under the MIT license, so you can use, modify and ship them in open-source or proprietary commercial projects while keeping the copyright and license notices. Review the licensing guide for retained third-party notices.
No. Decoding an existing image is separate from the QR Code AI creation service and its 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 does not start that trial, and directly encoded data remains in the symbol. The scanner itself is open source under the MIT license.