Barcode scanning
Stay organized with collections
Save and categorize content based on your preferences.

With ML Kit's barcode scanning API, you can read data encoded using most
standard barcode formats. Barcode scanning happens on the device, and doesn't
require a network connection.
Barcodes are a convenient way to pass information from the real world to your
app. In particular, when using 2D formats such as QR code, you can encode
structured data such as contact information or WiFi network credentials. Because
ML Kit can automatically recognize and parse this data, your app can respond
intelligently when a user scans a barcode.
For users who don't require custom UI, we recommend using the
Google code scanner. The code
scanner API uses the same inference model as the standard Barcode scanning API,
but returns only the most centralized barcode for a faster and more consistent
experience. Google code scanner is also safer and permission-less, and does not
require camera-related implementation or permissions.
iOS
Android
Google code scanner
Key capabilities
- Reads most standard formats
- Linear formats: Codabar, Code 39, Code 93, Code 128, EAN-8, EAN-13, ITF, UPC-A, UPC-E
- 2D formats: Aztec, Data Matrix, PDF417, QR Code
- Automatic format detection
- Scan for all supported barcode formats at once without having to specify
the format you're looking for, or boost scanning speed by restricting the
detector to only the formats you're interested in.
- Extracts structured data
- Structured data that's stored using one of the supported 2D formats is
automatically parsed. Supported information types include URLs,
contact information, calendar events, email addresses, phone
numbers, SMS message prompts, ISBNs, WiFi connection information,
geographic location, and AAMVA-standard driver information.
- Works with any orientation
- Barcodes are recognized and scanned regardless of their orientation:
right-side-up, upside-down, or sideways.
- Runs on the device
- Barcode scanning is performed completely on the device, and doesn't
require a network connection.
Note that this API does not recognize barcodes in these forms:
- 1D Barcodes with only one character
- Barcodes in ITF format with fewer than six characters, and this format is known to be flaky due to absence of checksum
- Barcodes encoded with FNC2, FNC3 or FNC4
- QR codes generated in the ECI mode
This API recognizes no more than 10 barcodes per API call.
Example results
|
Result |
Corners |
(49,125), (172,125), (172,160), (49,160) |
Raw value |
2404105001722 |
|
|
Result |
Corners |
(87,87) (612,87) (612,612) (87,612) |
Raw value |
WIFI:S:SB1Guest;P:12345;T:WEP;; |
WiFi information |
SSID |
SB1Guest |
Password |
12345 |
Type |
WEP |
|
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-02-28 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-28 UTC."],[[["ML Kit's Barcode Scanning API reads data from most standard barcode formats, including linear and 2D formats, without needing an internet connection."],["It automatically detects and parses structured data like contact info, WiFi credentials, and more from supported 2D formats, enabling intelligent app responses."],["The API works offline, recognizing barcodes in any orientation, and the Google Code Scanner offers a faster, safer, and permissionless option for basic scanning needs."],["While it supports a wide range of formats and data types, the API has limitations regarding certain 1D barcodes, ITF formats, and QR codes with specific encodings, recognizing a maximum of 10 barcodes per call."]]],["ML Kit's barcode scanning API reads data from most standard barcode formats on the device without needing a network connection. It automatically detects and parses structured data from 2D formats like QR codes, recognizing information such as URLs, contact details, and WiFi credentials. The API supports various linear and 2D formats, works with any barcode orientation, and offers a Google code scanner option for a faster, safer, permission-less experience. It does not recognize some formats including some 1D and ITF barcodes.\n"]]