Created
September 16, 2016 11:05
-
-
Save nicbou/8bbe7cc08744995c77d65f04b91e98c4 to your computer and use it in GitHub Desktop.
Pretty print JavaScript objects in Chrome Developer Tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Paste this in your console | |
Object.prototype.export=function(){e=JSON.stringify(this,0,2).replace(/\"([^(\")"]+)\":/g,"$1:");copy(e);console.log(e);console.warn('Copied to clipboard') }; | |
// Then do this for any object you want to copy | |
myObject.export(); | |
// And you will get a nicely formatted version of your object in the clipboard, | |
// properly spaced, without the properties wrapped in quotes. | |
const myObject = {a: 1, b: 'bee', c: [1,2,3]}; | |
myObject.export() | |
> { | |
> a: 1, | |
> b: "bee", | |
> c: [ | |
> 1, | |
> 2, | |
> 3 | |
> ] | |
> } | |
> Copied to clipboard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment