Instantly share code, notes, and snippets.

Embed
What would you like to do?
JSON Format Tools

python -mjson.tool

curl 'https://httpbin.org/json' -k -s | python -mjson.tool

To make it sorter, put an alias in your ~/.bash_profile, or ~/.config/fish/config.fish:

alias json="python -m json.tool"

Then you can do:

curl 'https://httpbin.org/json' -k -s | json

Bonus 1: After formatting, copy into clipboard:

curl 'https://httpbin.org/json' -k -s | json | pbcopy

Bonus 2: Format from clipboard:

pbpaste | json

Bonus 3: Format from clipboard, then copy into clipboard:

pbpaste | json | pbcopy

Sublime Text: Use JsFormat plugin

[demo]

Note:

  • Requires to set language type.

Visual Studio Code: Use Prettier Code Formatter

[demo]

Note:

  • Requires to set language type.
  • Prettier has a bug: You have to save content into a file before it can be formatted.

Chrome Developer Tools

Right click on Network Response Preview > Store as global variable.

copy(temp1)

// Or maybe you prefer this:

JSON.stringify(temp1, null, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment