QR & Barcodes5 min

How to Scan a Barcode with Your Webcam — In the Browser

Point your webcam or phone camera at a barcode or QR, decode it instantly in JavaScript with ZXing — no app, no upload, no server.

Zro7 QR & Barcode Scanner uses your camera through the browser's MediaDevices API. Frames are decoded in memory and never uploaded.

To scan a barcode with your webcam, open Zro7 QR & Barcode Scanner, allow camera access, and point the code at the viewport. ZXing decodes it in real time and prints the payload — for QR, WiFi, vCard, EAN, UPC, Code 128, Code 39, Data Matrix, and more.

How it works under the hood

  1. navigator.mediaDevices.getUserMedia({ video: true }) opens the camera.
  2. The video stream is drawn to a hidden <canvas> at ~30 FPS.
  3. @zxing/browser runs pattern detection on each frame in a Web Worker.
  4. First successful decode → payload is displayed; camera stays live so you can scan more.

Front vs rear camera

On mobile, Zro7 requests the rear camera (facingMode: 'environment') because it's the only one that focuses close enough to read a barcode. On laptops there's only the front cam — hold the code steady 15–20 cm away.

Formats supported

  • QR (all versions), Data Matrix, Aztec, PDF417.
  • EAN-8, EAN-13, UPC-A, UPC-E.
  • Code 39, Code 128, Codabar, ITF-14.

Why local scanning matters

A QR can encode a WiFi password, a Bitcoin address, or a login OTP. Any 'online QR scanner' that uploads your image sees that data. In-browser scanning keeps it in the tab.

Steps

  1. Open QR & Barcode Scanner.
  2. Grant camera permission.
  3. Point at the barcode; decoded payload appears within a second.
  4. Copy the result or scan another.

Frequently asked questions

Does it work on iPhone Safari?

Yes, iOS 14.3+. Camera access requires HTTPS, which zro7.dev serves.

Can I upload an image instead?

Yes — drop a photo of the barcode and it's decoded the same way.

Does it scan multiple codes in one frame?

Yes — ZXing returns all detected codes; Zro7 lists them.

Is the camera stream sent anywhere?

No. It never leaves the tab; check DevTools Network to confirm.

Why does my scan fail?

Usually focus or contrast — increase light, move 15–20 cm from the code, and hold steady for a second.

Related posts

← Back to blog