How to copy an object as JSON in Chrome DevTools
In Chrome’s DevTools Console, use copy(JSON.stringify(object, null, 2)) with the name of your object. The 2 adds two spaces of indentation, and DevTools writes the resulting text to your clipboard.
Copy an object from the Console
- Open the Console. If your object appears in a logged result, right-click it and choose Store as global variable. DevTools prints a variable name such as
temp1. - Enter
copy(JSON.stringify(temp1, null, 2))with that variable name. Paste the result into a text editor to see the JSON. - If you need the exact text the server sent, use Network and inspect the request’s Response tab. Serializing a JavaScript object can change the representation, and it throws for circular references or a plain
BigIntvalue.
Copy just one object from an API response
KeenKit JSON Viewer is available from the Chrome Web Store, Microsoft Edge Add-ons, and Firefox Add-ons. Add to Chrome Get it for Edge Get it for Firefox
If the data is already JSON and you can open the response directly in a tab, KeenKit JSON Viewer lets you select an object or array in the tree and choose Copy value. For example, select one record in an array to copy that record’s JSON. Choose Copy path if you want the reference to the record instead.
The extension reads eligible responses locally and copies to the system clipboard only when you use a Copy control. It keeps no persistent copy. Check the contents before pasting a record into a shared issue.
The source code is public under the MIT license: github.com/keenkit/json-viewer. JSON Viewer privacy policy