Access USB Devices on the Web - Chrome Developers (2023)

If I said plainly and simply "USB", there is a good chance that you will immediately think of keyboards, mice, audio, video, and storage devices. You're right, but you'll find other kinds of Universal Serial Bus (USB) devices out there.

These non-standardized USB devices require hardware vendors to write platform-specific drivers and SDKs in order for you (the developer) to take advantage of them. Sadly this platform-specific code has historically prevented these devices from being used by the Web. And that's one of the reasons the WebUSB API has been created: to provide a way to expose USB device services to the Web. With this API, hardware manufacturers will be able to build cross-platform JavaScript SDKs for their devices.

But most importantly this will make USB safer and easier to use by bringing it to the Web.

Let's see the behavior you could expect with the WebUSB API:

  1. Buy a USB device.
  2. Plug it into your computer. A notification appears right away, with the right website to go to for this device.
  3. Click the notification. The website is there and ready to use!
  4. Click to connect and a USB device chooser shows up in Chrome where you can pick your device.


What would this procedure be like without the WebUSB API?

  1. Install a platform-specific application.
  2. If it's even supported on my operating system, verify that I've downloaded the right thing.
  3. Install the thing. If you're lucky, you'll get no scary OS prompts or popups warning you about installing drivers/applications from the internet. If you're unlucky, the installed drivers or applications malfunction and harm your computer. (Remember, the web is built to contain malfunctioning websites).
  4. If you only use the feature once, the code stays on your computer until you think to remove it. (On the Web, the space for unused is eventually reclaimed.)

# Before I start

This article assumes you have some basic knowledge of how USB works. If not, I recommend reading USB in a NutShell. For background information about USB, check out the official USB specifications.

The WebUSB API is available in Chrome 61.

# Available for origin trials

In order to get as much feedback as possible from developers using the WebUSB API in the field, we've previously added this feature in Chrome 54 and Chrome 57 as an origin trial.

The latest trial has successfully ended in September 2017.

(Video) Connecting hardware devices to the web

# Privacy and security

# HTTPS only

Because of this feature's power, it only works on secure contexts. This means you'll need to build with TLS in mind.

# User gesture required

As a security precaution, navigator.usb.requestDevice() may only be called through a user gesture such as a touch or mouse click.

# Feature Policy

A feature policy is a mechanism that allows developers to selectively enable and disable various browser features and APIs. It can be defined via an HTTP header and/or an iframe "allow" attribute.

You can define a feature policy that controls whether the usb attribute is exposed on the Navigator object, or in other words if you allow WebUSB.

Below is an example of a header policy where WebUSB is not allowed:

Feature-Policy: fullscreen "*"; usb "none"; payment "self"

Below is another example of a container policy where USB is allowed:

<iframe allowpaymentrequest allow="usb; fullscreen"></iframe>

# Let's start coding

The WebUSB API relies heavily on JavaScript Promises. If you're not familiar with them, check out this great Promises tutorial. One more thing, () => {} are simply ECMAScript 2015 Arrow functions.

# Get access to USB devices

You can either prompt the user to select a single connected USB device using navigator.usb.requestDevice() or call navigator.usb.getDevices() to get a list of all connected USB devices the website has been granted access to.

The navigator.usb.requestDevice() function takes a mandatory JavaScript object that defines filters. These filters are used to match any USB device with the given vendor (vendorId) and, optionally, product (productId) identifiers. The classCode, protocolCode, serialNumber, and subclassCode keys can also be defined there as well.

Access USB Devices on the Web - Chrome Developers (1)

For instance, here's how to get access to a connected Arduino device configured to allow the origin.

(Video) Remote debug web page on Android with Chrome DevTools

navigator.usb.requestDevice({ filters: [{ vendorId: 0x2341 }] })
.then(device => {
console.log(device.productName); // "Arduino Micro"
console.log(device.manufacturerName); // "Arduino LLC"
.catch(error => { console.error(error); });

Before you ask, I didn't magically come up with this 0x2341 hexadecimal number. I simply searched for the word "Arduino" in this List of USB ID's.

The USB device returned in the fulfilled promise above has some basic, yet important information about the device such as the supported USB version, maximum packet size, vendor, and product IDs, the number of possible configurations the device can have. Basically it contains all fields in the device USB Descriptor.

// Get all connected USB devices the website has been granted access to.
navigator.usb.getDevices().then(devices => {
devices.forEach(device => {
console.log(device.productName); // "Arduino Micro"
console.log(device.manufacturerName); // "Arduino LLC"

By the way, if a USB device announces its support for WebUSB, as well as defining a landing page URL, Chrome will show a persistent notification when the USB device is plugged in. Clicking this notification will open the landing page.

Access USB Devices on the Web - Chrome Developers (2)

# Talk to an Arduino USB board

Okay, now let's see how easy it is to communicate from a WebUSB compatible Arduino board over the USB port. Check out instructions at to WebUSB-enable your sketches.

Don't worry, I'll cover all the WebUSB device methods mentioned below later in this article.

let device;

navigator.usb.requestDevice({ filters: [{ vendorId: 0x2341 }] })
.then(selectedDevice => {
device = selectedDevice;
return; // Begin a session.
.then(() => device.selectConfiguration(1)) // Select configuration #1 for the device.
.then(() => device.claimInterface(2)) // Request exclusive control over interface #2.
.then(() => device.controlTransferOut({
requestType: 'class',
recipient: 'interface',
request: 0x22,
value: 0x01,
index: 0x02})) // Ready to receive data
.then(() => device.transferIn(5, 64)) // Waiting for 64 bytes of data from endpoint #5.
.then(result => {
const decoder = new TextDecoder();
console.log('Received: ' + decoder.decode(;
.catch(error => { console.error(error); });

Keep in mind that the WebUSB library I'm using is just implementing one example protocol (based on the standard USB serial protocol) and that manufacturers can create any set and types of endpoints they wish. Control transfers are especially nice for small configuration commands as they get bus priority and have a well defined structure.

And here's the sketch that has been uploaded to the Arduino board.

// Third-party WebUSB Arduino library
#include <WebUSB.h>

WebUSB WebUSBSerial(1 /* https:// */, "");

#define Serial WebUSBSerial

(Video) How to USB flash drive Chromebook

void setup() {
while (!Serial) {
; // Wait for serial port to connect.
Serial.write("WebUSB FTW!");

void loop() {
// Nothing here for now.

The third-party WebUSB Arduino library used in the sample code above does basically two things:

  • The device acts as a WebUSB device enabling Chrome to read the landing page URL.
  • It exposes a WebUSB Serial API that you may use to override the default one.

Look at the JavaScript code again. Once I get the device picked by the user, runs all platform-specific steps to start a session with the USB device. Then, I have to select an available USB Configuration with device.selectConfiguration(). Remember that a configuration specifies how the device is powered, its maximum power consumption and its number of interfaces. Speaking of interfaces, I also need to request exclusive access with device.claimInterface() since data can only be transferred to an interface or associated endpoints when the interface is claimed. Finally calling device.controlTransferOut() is needed to set up the Arduino device with the appropriate commands to communicate through the WebUSB Serial API.

From there, device.transferIn() performs a bulk transfer onto the device to inform it that the host is ready to receive bulk data. Then, the promise is fulfilled with a result object containing a DataView data that has to be parsed appropriately.

If you're familiar with USB, all of this should look pretty familiar.

# I want more

The WebUSB API lets you interact with the all USB transfer/endpoint types:

  • CONTROL transfers, used to send or receive configuration or command parameters to a USB device, are handled with controlTransferIn(setup, length) and controlTransferOut(setup, data).
  • INTERRUPT transfers, used for a small amount of time sensitive data, are handled with the same methods as BULK transfers with transferIn(endpointNumber, length) and transferOut(endpointNumber, data).
  • ISOCHRONOUS transfers, used for streams of data like video and sound, are handled with isochronousTransferIn(endpointNumber, packetLengths) and isochronousTransferOut(endpointNumber, data, packetLengths).
  • BULK transfers, used to transfer a large amount of non-time-sensitive data in a reliable way, are handled with transferIn(endpointNumber, length) and transferOut(endpointNumber, data).

You may also want to have a look at Mike Tsao's WebLight project which provides a ground-up example of building a USB-controlled LED device designed for the WebUSB API (not using an Arduino here). You'll find hardware, software, and firmware.

# Revoke access to a USB device

The website can clean up permissions to access a USB device it no longer needs by calling forget() on the USBDevice instance. For example, for an educational web application used on a shared computer with many devices, a large number of accumulated user-generated permissions creates a poor user experience.

// Voluntarily revoke access to this USB device.
await device.forget();

As forget() is available in Chrome 101 or later, check if this feature is supported with the following:

(Video) How to Enable Developer Mode and USB Booting Chromebook

if ("usb" in navigator && "forget" in USBDevice.prototype) {
// forget() is supported.

# Limits on transfer size

Some operating systems impose limits on how much data can be part of pending USB transactions. Splitting your data into smaller transactions and only submitting a few at a time helps avoid those limitations. It also reduces the amount of memory used and allows your application to report progress as the transfers complete.

Because multiple transfers submitted to an endpoint always execute in order, it is possible to improve throughput by submitting multiple queued chunks to avoid latency between USB transfers. Every time a chunk is fully transmitted it will notify your code that it should provide more data as documented in the helper function example below.

const BULK_TRANSFER_SIZE = 16 * 1024; // 16KB

async function sendRawPayload(device, endpointNumber, data) {
let i = 0;
let pendingTransfers = [];
let remainingBytes = data.byteLength;
while (remainingBytes > 0) {
const chunk = data.subarray(
// If we've reached max number of transfers, let's wait.
if (pendingTransfers.length == MAX_NUMBER_TRANSFERS) {
await pendingTransfers.shift();
// Submit transfers that will be executed in order.
pendingTransfers.push(device.transferOut(endpointNumber, chunk));
remainingBytes -= chunk.byteLength;
// And wait for last remaining transfers to complete.
await Promise.all(pendingTransfers);

# Tips

Debugging USB in Chrome is easier with the internal page about://device-log where you can see all USB device related events in one single place.

Access USB Devices on the Web - Chrome Developers (3)

The internal page about://usb-internals also comes in handy and allows you to simulate connection and disconnection of virtual WebUSB devices. This is be useful for doing UI testing without for real hardware.

Access USB Devices on the Web - Chrome Developers (4)

On most Linux systems, USB devices are mapped with read-only permissions by default. To allow Chrome to open a USB device, you will need to add a new udev rule. Create a file at /etc/udev/rules.d/50-yourdevicename.rules with the following content:

SUBSYSTEM=="usb", ATTR{idVendor}=="[yourdevicevendor]", MODE="0664", GROUP="plugdev"

where [yourdevicevendor] is 2341 if your device is an Arduino for instance. ATTR{idProduct} can also be added for a more specific rule. Make sure your user is a member of the plugdev group. Then, just reconnect your device.

Microsoft OS 2.0 Descriptors used by the Arduino examples only work on Windows 8.1 and later. Without that Windows support still requires manual installation of an INF file.

# Resources

Send a tweet to @ChromiumDev using the hashtag #WebUSB and let us know where and how you're using it.

# Acknowledgements

Thanks to Joe Medley for reviewing this article.

(Video) How to Access Android Developer Options on your Chromebook Chrome OS


Can a website access USB? ›

Chrome lets you connect a website to your computer's USB, Serial, and HID devices. For example, keyboard, headset, speaker, gamepad, camera, and even microcontroller. On Android, you can connect a website to a USB device.

How do I access connected USB devices? ›

To use Device Manager to display USB info: Select Windows logo key+R, enter devmgmt. msc into the pop-up box, and then select Enter. In Device Manager, select your computer so that it's highlighted.

How do I enable USB ports blocked by administrator? ›

Manual Procedure to Enable USB Ports in Windows 10, 8, 7 OS
  1. Go to Start Menu, and type “devmgmt. msc” in the Search box to launch the Device Manager.
  2. Hit on the Universal Serial Bus Controllers.
  3. Now, the user will get the list of available USB ports. Right-click on the USB port option and disable/enable the port.
Jan 6, 2023

How do I enable USB permissions? ›

Follow the steps below:
  1. Right-click the USB's drive on File Explorer and select Properties.
  2. Click the Security tab.
  3. Select an Owner/User and click Edit.
  4. Check all the options on the Allowed column, select OK and then Apply.
Jan 28, 2018

How do I allow USB permissions? ›

Enabling USB Debugging on an Android Device
  1. On the device, go to Settings > About <device>.
  2. Tap the Build number seven times to make Settings > Developer options available.
  3. Then enable the USB Debugging option. ...
  4. If you are running Windows 8, you must configure the USB connection as Camera (PTP).

How do I enable USB backend in Chrome? ›

Load chrome://inspect and ensure that the Discover USB devices option is checked. Check that the phone appears as an available device. It may appear as “Offline” until the Allow button is tapped on the “Allow USB debugging” prompt which appears on the device.

Does Google Chrome have a USB port? ›

It doesn't have any USB-A ports for connecting older peripherals; if you want to do that, you need to attach a dongle or dock.

What is USB in Chrome? ›

Use the chrome. usb API to interact with connected USB devices. This API provides access to USB operations from within the context of an app. Using this API, apps can function as drivers for hardware devices. Errors generated by this API are reported by setting runtime.

How do I access connected devices? ›

View devices connected to your network and review data usage
  1. Open the Google Home app .
  2. Tap Wi-Fi .
  3. At the top, tap Devices.
  4. Tap a specific device and a tab to find additional details. Speed: Real time usage is how much data your device is currently using.

How do I check USB access? ›

To scan for hardware changes, follow these steps:
  1. Click Start, and then click Run. ...
  2. Type devmgmt. ...
  3. In Device Manager, click your computer so that it is highlighted.
  4. Click Action, and then click Scan for hardware changes.
  5. Check the USB device to see whether it is working.

Where can I see all my connected devices? ›

See devices with account access
  • Go to your Google Account.
  • On the left navigation panel, select Security .
  • On the Your devices panel, select Manage all devices.
  • You'll see devices where you're currently signed in to your Google Account or have been in the last few weeks.

How to bypass USB access denied? ›

Navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ENUM\USB using the tree to expand folders. Right Click the USB folder and select Permissions...
  1. Select Apply to apply these changes. ...
  2. Select Apply in the Permissions for USB dialog box if necessary, then select OK to exit.
  3. Retry the installation.
Dec 8, 2022

Why is access denied on USB? ›

The error "Location is not accessible, Access is denied" may appear when a storage device, external or not, has restricted read or write permissions.

How do I change USB preferences? ›

On some devices, it might be accessible from Settings > System > Advanced. Either way, once on the Developer Options page, scroll down a bit and tap on 'Default USB Configuration.

How do I enable device permissions? ›

Change app permissions
  1. On your phone, open the Settings app.
  2. Tap Apps.
  3. Tap the app you want to change. If you can't find it, tap See all apps. ...
  4. Tap Permissions. If you allowed or denied any permissions for the app, you'll find them here.
  5. To change a permission setting, tap it, then choose Allow or Don't allow.

How do I enable permissions in Chrome? ›

Change settings for a site
  1. On your Android phone or tablet, open the Chrome app .
  2. Go to a site.
  3. To the left of the address bar, tap Lock. Permissions.
  4. Tap the permission you want to update. To change a setting, select it. To clear the site's settings, tap Reset permissions.

How do I fix USB device Cannot be recognized? ›

USB Device Not Recognized Error: Fixed [8 Possible Solutions]
  1. #1) Restart Your Computer.
  2. #2) Update Computer.
  3. #3) Change USB Root Hub Settings.
  4. #4) Update USB Driver.
  5. #5) Check And Change Ports.
  6. #6) Change USB Selective Suspended Settings.
  7. #7) Format Your Drive.
  8. #8) Data Recovery Software.
Dec 30, 2022

Why isn't my Chromebook recognizing my USB device? ›

Your Chromebook might not support the external storage device you're trying to use. Make sure your external storage device's format is supported. If your storage device is supported, make sure your Chromebook is using the latest version of Chrome OS.

How do I inspect a device in Chrome? ›

Inspect Website from Laptop

Go to chrome://inspect#devices . Make sure that the Discover USB devices checkbox is enabled.

What ports are blocked by Chrome? ›

It helps developers by keeping the web platform safe for users. HTTP servers using port 5060 or port 5061 will be inaccessible.

What ports does Google Chrome use? ›

For DNS, chrome will send a DNS Query on port 53.

Can hackers access USB? ›

Note that USB flash drives are not the only hardware at risk: human interface devices or "HID" such as keyboards, mice, smartphone chargers, or any other connected object can be tampered with by malicious people. And the consequences are severe: data theft or destruction, sabotage, ransom demands, etc.

What does a USB bootloader do? ›

A Bootloader is a program that allows you to load other programs via a more convenient interface like a standard USB cable. When you power-up or reset your microcontroller board, the bootloader checks to see if there is an upload request. If there is, it will upload the new program and burn it into Flash memory.

What are site settings on Chrome? ›

Site Settings.

To change permissions and data storage on all sites you've visited, you can also select View permissions and data stored across sites. Cookies: Cookies are files created by sites you visit. They make your online experience easier and save browsing information. Learn how to manage cookies.

How do I find my USB device in Device Manager? ›

In Device Manager, click View, and click Devices by connection. In Devices by connection view, you can easily see the USB Mass Storage device under the Intel® USB 3.0 eXtensible Host Controller category.

How do I identify a USB device? ›

icon, or something similar), right-click the device, and select Properties. Select the Details tab. View the plug-and-play Hardware ID information in the Property selection list. Locate the device Vendor ID and Product ID in the data displayed in the Value list.

How do I access an unknown device? ›

Unknown Device in Device Manager
  1. Open Device Manager. ...
  2. Type devmgmt. ...
  3. Device Manager opens (Figure 2). ...
  4. Right click on the "Unknown Device" and select Properties (Figure 3). ...
  5. Select the Details tab. ...
  6. The top line should list something like: PCI\VEN_8086&DEV_1916.
Feb 21, 2021

How can I see hidden USB devices? ›

For Windows 8 and later: From Start, search for device manager, and select Device Manager from the search results. Troubleshoot the devices and drivers in Device Manager. Note Click Show hidden devices on the View menu in Device Manager before you can see devices that are not connected to the computer.

What is USB access control? ›

USB device control reduces the risk of data loss and theft by managing and blocking unauthorized access of USB devices and removable storage media. This supports your company's security stack and provides an added layer of security against malware, ransomware, and other computer viruses.

How do I access a device using an IP address? ›

Remotely access a PC using IP address on the same network

On the client's PC, input “remote desktop connection”, and double click "Remote Desktop Connection" to open it. Step 2. Now, you'll be in Remote Desktop Connection. Type in the PC name or the IP address of the remote PC and click "Connect".

How do I force Windows to remove and re detect a USB device? ›

Open Device Manager and then disconnect the USB device from your computer. Wait a few moments and then reconnect the device. You should see a device disappear from Device Manager when you remove the device, and it should appear again when you reconnect the device. Connect the USB device to another USB port.

How do I remove write protection from a USB port? ›

Take the USB stick you've tried to write to and look for that switch, usually located on the side, and it might also be labeled as “Lock” or “Write Protection.” Switch it to the other position, reinsert it, and then attempt to transfer data to the memory stick again.

How do I disable administrator permission prompts on USB? ›

I also had to figure it out and I thought I would share the answer:
  1. Go to windows explorer.
  2. Right mouse the drive in question.
  3. Go to properties.
  4. Select security tab.
  5. Change permissions to full.

How do I remove USB restrictions in Windows 10? ›

To disable removable storage access on Windows 10, use these steps:
  1. Open Start.
  2. Search for gpedit. ...
  3. Browse the following path: Computer Configuration > Administrative Templates > System > Removable Storage Access.
  4. On the right side, double-click the All Removable Storage classes: Deny all access policy.
May 17, 2022

Can websites access your files? ›

Due to security concerns, access to local files from browsers is restricted. Web browsers (and JavaScript) can only access local files with user permission.

Can websites access your hard drive? ›

In general a website can not access files on your hard drive or their meta information. Nevertheless you should be aware of a couple of things: there might be security flaws in your browser, that lets attackers hijack your browser or even your system.

Can a hacker hack a USB? ›

Hackers can use USB sticks to infect your computers with malware that can detect when you plug in the USB drive and then download malicious code.

Can hackers access flash drives? ›

Note that USB flash drives are not the only hardware at risk: human interface devices or "HID" such as keyboards, mice, smartphone chargers, or any other connected object can be tampered with by malicious people. And the consequences are severe: data theft or destruction, sabotage, ransom demands, etc.

Can Chrome access local files? ›

For security reasons, by default the Chrome browser does not allow extensions to access local files. If you want the accelerator to access local files (locations of "file:///...", instead of "http://" or "https://"), you must configure Chrome to allow the access.

Can website owners see your IP? ›

Every web user has an IP address – it's given to you by your internet service provider, and every device on your home network shares the same unique IP address. Pro tip: To find your IP address, simply Google 'my ip. ' When you access a website, that website can see your IP address.

Can websites download things without you knowing? ›

Websites you visit can download and install software without your knowledge or approval. This is called a drive-by download. The objective is usually to install malware, which may: Record what you type and what sites you visit.

Does Chrome scan your hard drive? ›

If left in your system, this software may perform unwanted actions, such as changing your Chrome settings without your approval. Chrome periodically scans your device to detect potentially unwanted software.

Does Google check your files drive? ›

Every file you upload, every Doc or Sheet you create — Google's algorithm is right there with you. Your Google Drive is not private at all.

Can Google access your Drive files? ›

The content you save on Drive is private to you, from others, unless you choose to share it. Learn how to share or stop sharing files in Google Drive. Google respects your privacy. We access your private content only when we have your permission or are required to by law.

Which device Cannot be hacked? ›

Sirin Labs Finney U1. Sirin Labs are in the phone business and is the most secure Phone for a while now. Their sole goal is to provide users with the utmost security and transparency features. The Sirin Labs Finney U1 is another advancement when compared to their Solarin phone.

What software do hackers use to hack? ›

Some of the most famous hacking tools in the market are Nmap (Network Mapper), Nessus, Nikto, Kismet, NetStumbler, Acunetix, Netsparker, and Intruder, Nmap, Metasploit, Aircrack-Ng, etc.

What are the signs of a hacked device? ›

How to know if your phone is hacked
  • 1: You notice something you don't recognize on your phone. Look out for apps you didn't download, text messages you didn't send, purchases you didn't make, and suspicious phone calls.
  • 2: Your phone works slowly. ...
  • 3: Mysterious data usage spikes. ...
  • 4: Strange behavior. ...
  • 5: Pop-ups.
Jan 12, 2023

How do hackers use USB? ›

Hackers can also use USB drives to gain access to sensitive information kept on a computer or network. Hackers may infect one or more USB drives with a virus or Trojan, that when run, will provide hackers with access to logins, passwords, and information on the user's computer or the network the computer is connected ...

Can you tell if someone opened your flash drive? ›

Just have a look at when the files where last accessed by right clicking on the files you want to see if they are accessed and select properties. It will show the last access date (when the file was last opened), Last modified date (when the file was last saved).

How do I stop someone from using my USB storage device? ›

If a USB storage device is not already installed on the computer
  1. Start Windows Explorer, and then locate the %SystemRoot%\Inf folder.
  2. Right-click the Usbstor. ...
  3. Click the Security tab.
  4. In the Group or user names list, add the user or group that you want to set Deny permissions for.


1. How To Install APK FILES On Chromebook WITHOUT Developer Mode | UPDATED 2023
2. Chrome 61: JavaScript Modules, WebUSB, WebShare and more
(Google Chrome Developers)
3. How To Use A Flash Drive On A Chromebook
(Tech Time With Timmy)
4. How to Use Flash Drive with Chromebook
(Merced Union High School District)
5. Accessing USB from Linux on Chromebook
6. Unlock your Chromecast's full potential by adding a USB C Hub
(Geek Street)
Top Articles
Latest Posts
Article information

Author: Ouida Strosin DO

Last Updated: 03/10/2023

Views: 6002

Rating: 4.6 / 5 (76 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Ouida Strosin DO

Birthday: 1995-04-27

Address: Suite 927 930 Kilback Radial, Candidaville, TN 87795

Phone: +8561498978366

Job: Legacy Manufacturing Specialist

Hobby: Singing, Mountain biking, Water sports, Water sports, Taxidermy, Polo, Pet

Introduction: My name is Ouida Strosin DO, I am a precious, combative, spotless, modern, spotless, beautiful, precious person who loves writing and wants to share my knowledge and understanding with you.