WebUSB is a JavaScript API that lets a web page communicate directly with USB devices after the user explicitly selects a device in a browser prompt. Among Web APIs, the WebUSB API exposes low-level USB transfers to web applications, so hardware such as microcontroller boards, lab instruments and label printers can be configured from a browser without installing native drivers or desktop software.
The specification is developed as a Draft Community Group Report in the W3C Web Platform Incubator Community Group. It ships in Chromium-based browsers such as Chrome, Edge and Opera on desktop and Android, while Firefox and Safari have declined to implement it over security and privacy concerns.
How WebUSB connects a page to a device
WebUSB works through a permission-gated, promise-based flow: the page requests a device, the user picks one from a browser chooser, and the page then opens it and exchanges data through standard USB transfer types. A call to navigator.usb.requestDevice() must be triggered by a user gesture such as a click, and it accepts filters on vendor ID, product ID or interface class to limit the list shown.
After selection, the returned USBDevice object goes through a fixed sequence. The table below summarizes the main steps and the method used at each one.
| Step | Method | Purpose |
|---|---|---|
| Request access | navigator.usb.requestDevice() | User chooses a device in a prompt |
| Open session | device.open() | Starts communication with the device |
| Select configuration | device.selectConfiguration(1) | Activates a device configuration |
| Claim interface | device.claimInterface(n) | Gains exclusive use of an interface |
| Transfer data | transferIn() or transferOut() | Reads or writes endpoint data |
| Release and close | releaseInterface() and close() | Frees the device for other software |
Once access is granted, navigator.usb.getDevices() returns previously authorized devices without a new prompt, and connect and disconnect events report hot-plugging. Optional WebUSB descriptors in device firmware can advertise a landing page URL, which Chromium may surface as a notification when the device is plugged in.
USB transfer types available to web code
WebUSB exposes four USB transfer types, mirroring the USB 2.0 specification, and the right choice depends on how the device firmware defines its endpoints. All transfers return promises that resolve with a status such as ok, stall or babble.
| Transfer type | WebUSB methods | Characteristics | Typical use |
|---|---|---|---|
| Control | controlTransferIn/Out() | Setup packets, guaranteed delivery | Commands and configuration |
| Bulk | transferIn/Out() | Reliable, no timing guarantee | Firmware images, file data |
| Interrupt | transferIn/Out() | Small, polled at fixed intervals | Status updates, sensor readings |
| Isochronous | isochronousTransferIn/Out() | Timed delivery, no retries | Audio and video streams |
Control transfers specify a request type, recipient, request code, value and index, exactly as in the USB protocol. Developers therefore need the device’s protocol documentation or firmware source; WebUSB moves bytes but does not interpret them.
Security model and protected device classes
The WebUSB security model rests on explicit user choice, secure contexts and a blocklist. The API is available only over HTTPS or localhost, cannot be invoked without a user gesture, and can be disabled by Permissions Policy in embedded frames or by enterprise administrators.
Chromium also refuses to expose protected interface classes that the operating system already handles, because raw access could enable keylogging or data theft. Interfaces for HID, mass storage, audio, video, smart cards and wireless controllers are blocked, and a maintained blocklist excludes specific devices known to be dangerous, such as some security keys.
Critics argue that users cannot judge what a page will do with a device once access is granted. A malicious site could, for example, reflash firmware on a poorly protected device. This concern is the main reason Mozilla and Apple rejected the API, so cross-browser support remains unlikely.
WebUSB compared with related hardware APIs
WebUSB belongs to a family of device access APIs, each targeting a different layer. The comparison below helps decide which one fits a given device.
| API | Device scope | Abstraction level | Best fit |
|---|---|---|---|
| WebUSB | Generic USB devices | Raw endpoints and transfers | Vendor-specific USB protocols |
| WebHID | Human interface devices | HID reports | Game controllers, macro keypads |
| Web Serial | Serial ports, USB serial adapters | Byte streams | Arduino boards, modems, GPS units |
| Web Bluetooth API | Bluetooth Low Energy peripherals | GATT services | Fitness trackers, beacons |
| Gamepad API | Standard game controllers | Mapped buttons and axes | Browser games |
A common mistake is choosing WebUSB for a device that already enumerates as a serial port or HID device. The operating system claims those interfaces, so WebUSB cannot open them, and Web Serial or WebHID is the correct route.
Practical use and limitations
WebUSB is most valuable when eliminating native software removes real friction. Firmware update tools, Android device flashing utilities, educational microcontroller editors and point-of-sale peripherals are the clearest successes.
| Situation | Recommendation | Reason |
|---|---|---|
| Custom device, own firmware | Use WebUSB | Full control over descriptors and protocol |
| Audience uses Safari or Firefox | Provide a native fallback | No support in those browsers |
| Device is a keyboard or mouse | Use WebHID instead | HID class is protected |
| Windows device without WinUSB | Add WinUSB descriptors | Driver must allow user-space access |
Operating system drivers create the most practical friction. On Windows, a device must bind to the WinUSB driver, ideally through Microsoft OS descriptors in firmware; on Linux, udev rules may be needed for permission. Only one program can claim an interface at a time, so a running desktop tool can block the web page.
Robust implementations also handle disconnects during transfers, retry stalled endpoints with clearHalt(), and keep large transfers in chunks that match the endpoint packet size. Long firmware uploads should report progress so that users do not unplug the device mid-write, which can leave hardware in an unrecoverable bootloader state.
Put simply
WebUSB lets a website talk to a gadget plugged into a computer, such as a small circuit board or a printer, without asking the user to install special software first.
The browser acts as a careful doorkeeper. A website cannot see any device until the user picks it from a list, and sensitive devices like keyboards and memory sticks stay off limits. The key point: it trades convenience for trust, which is why only some browsers offer it.
In practice
A school robotics program gives students microcontroller boards running firmware with WebUSB descriptors. Instead of installing a desktop programming tool on 30 locked-down Chromebooks, the teacher points students to a web-based editor served over HTTPS.
Each student clicks Connect, selects the board from the browser prompt, and the page claims the vendor interface, then sends a compiled program of about 40 KB through bulk transfers. Uploading takes a few seconds, and the board restarts with the new code. The program saves hours of setup time each term, while families using Safari at home receive instructions for a small offline uploader as a fallback.