Skip to content

Instantly share code, notes, and snippets.

@harish2704
Created September 25, 2018 06:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harish2704/67824c25afdf12e018dc1d98211c9336 to your computer and use it in GitHub Desktop.
Save harish2704/67824c25afdf12e018dc1d98211c9336 to your computer and use it in GitHub Desktop.
Pretty print / format JSON from STDIN using nodejs. single line solution.
node -e "console.log( JSON.stringify( JSON.parse(require('fs').readFileSync(0) ), null, 1 ))"
# Exapmle usage
# echo unformated.json | node -e "console.log( JSON.stringify( JSON.parse(require('fs').readFileSync(0) ), null, 1 ))"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment