---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---

# toJSON

The `toJSON()` method of the Device interface is a serializer;
it returns a JSON representation of the Device object.

To get a JSON string, you can use `JSON.stringify(device)` directly; it will call `toJSON()` automatically.

## Syntax

```js
toJSON()
```

### Return value

A JSON object that is the serialization of the Device object.
