Get to know MDN better
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is available in Dedicated Web Workers.
The Web Serial API provides a way for websites to read from and write to serial devices. These devices may be connected via a serial port, or be USB or Bluetooth devices that emulate a serial port.
The Web Serial API is one of a set of APIs that allow websites to communicate with peripherals connected to a user's computer. It provides the ability to connect to devices that are required by the operating system to communicate via the serial API, rather than USB which can be accessed via the WebUSB API, or input devices that can be accessed via WebHID API.
Examples of serial devices include 3D printers, and microcontrollers such as the BBC micro:bit board.
Provides attributes and methods for finding and connecting to serial ports from a web page.
SerialPortProvides access to a serial port on the host device.
Returns a Serial object, which represents the entry point into the Web Serial API to enable the control of serial ports.
WorkerNavigator.serial Read onlyReturns a Serial object, which represents the entry point into the Web Serial API to enable the control of serial ports.
Controls whether the current document is allowed to use the Web Serial API to communicate with serial devices, either directly connected via a serial port, or via USB or Bluetooth devices emulating a serial port.
The following examples demonstrate some of the functionality provided by the Web Serial API.
The following example shows how to check for available ports and allows the user to grant it permission to access additional ports.
The connect and disconnect events let sites react when a device is connected or disconnected from the system. The getPorts() method is then called to see connected ports that the site already has access to.
If the site doesn't have access to any connected ports it has to wait until it has user activation to proceed. In this example we use a click event handler on a button for this task. A filter is passed to requestPort() with a USB vendor ID in order to limit the set of devices shown to the user to only USB devices built by a particular manufacturer.
The following example shows how to read data from a port. The outer loop handles non-fatal errors, creating a new reader until a fatal error is encountered and SerialPort.readable becomes null.
| Web Serial API # serial-interface |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Apr 25, 2026 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.