Skip to Content
Platform.Ontology

Shape Detection: BarcodeDetector

Finds and reads barcodes and QR codes in an image or camera frame.

Works without askingHardware and accessoriesShape detectionWeb browsersWhile you use it

In one line

Can find barcodes and QR codes in a picture or camera view

Finds and reads barcodes and QR codes in an image or camera frame.

Turns pixels into decoded strings (product codes, URLs, tickets). Runs on-device with no prompt, once the page has the image.

What it can and can't do

What the user does: You tap Scan QR code and allow your camera, or you pick a photo.

It can

  • Find a barcode or QR code in a photo
  • Scan live from your camera, once you allow it
  • Tell the page what the code says

It cannot

  • Use your camera without its own camera permission
  • Scan in Firefox or in Safari without a special setting
  • Always find codes in a blurry or tilted image
  • See the rest of your camera roll

How it differs between platforms: Chrome, Edge and Android Chrome support it, though not on every device. Safari and Firefox lack full support.

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported882021-01-19Android 83; desktop 88
EdgePartial832020-05-21Supported on macOS only. Before Chrome 113, on macOS Ventura (13) and above, this interface silently failed. See <a href="https://crbug.com/40245611"&gt;bug 402456
FirefoxNot supportedNot availableNot listedNone
SafariBehind a flag17Not listedBehind flag
Safari on iPhoneBehind a flag17Not listedBehind flag
Chrome on AndroidSupported832020-05-19None
Samsung InternetSupported13.02020-12-02None

How a site asks for it

APInew BarcodeDetector({formats}).detect(imageBitmap)
Browser compat keysapi.BarcodeDetector
How access is grantednone
What the user seesNone for the API; camera needs getUserMedia prompt
Needs a secure context (HTTPS)Yes
Needs a user gestureNo
How long it lastsPer origin
How to take it backSite settings
Inside an iframeSame as top level; cross-origin iframes need a permissions policy where listed

Typical flow

  1. Call the API
  2. Browser applies its access rules
  3. Page receives the result

Data you get

What comes back: Finds and reads barcodes and QR codes in an image or camera frame.
Shape: object
How often: on demand

FieldTypeUnitRangePrecision
rawValuestringNonedecoded textNot listed
formatenumNoneqr_code, ean_13, code_128, aztec, pdf417, data_matrix and more (about 14)Not listed
boundingBoxobjectpixelsimage rectNot listed
cornerPointslistpixels4 pointsNot listed

Technical limits

  • Chrome only in practice
  • Format list varies by OS (Android, ChromeOS, macOS; Windows partial)
  • FaceDetector and TextDetector exist only behind flags

The story

What it is

A page can read barcodes and QR codes from a picture or the camera.

For you

You hold your camera to a QR code or barcode and the page reads it in a flash. The camera still asks permission first.

For makers

Makers can scan tickets, products and payments without a native app, using the camera you already approved. The reading runs on your device so images do not need to leave it.

Where you see it

TypeExampleApps
shoppingA store site scans a barcode to look up a product in the aisle.None named
liveAn event site scans tickets at the door with a phone.Eventbrite
paymentsA payments site scans a QR code to pay.None named
travelAn airline site reads a boarding pass code.None named
enterpriseA warehouse web tool scans shelf labels and counts stock.None named
securityA phisher puts a fake QR code on a flyer that leads to a bad site.None named

Risks

  • Fake QR codes
  • Limited browser support

What the platform says

Good uses and abuse

Legitimate uses

  • Ticket and product scanning
  • QR sign in

Known abuse

  • Reading codes from photos silently

Scores

ScoreValueMeaning
Sensitivity2 of 5How revealing the data is
Utility4 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bitsNot ratedRough identifying entropy, when known

History

  • 2019-02, Chrome 83: Android first (desktop 88)
  • 2023-09, Safari 17: Behind a flag in Safari

Sources

How well checked: Checked against real behavior.

On this page