Skip to content

Instantly share code, notes, and snippets.

@DamonOehlman
Created March 30, 2012 04:15
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 DamonOehlman/2246415 to your computer and use it in GitHub Desktop.
Save DamonOehlman/2246415 to your computer and use it in GitHub Desktop.
Prettify JSON
var fs = require('fs');
fs.readFile(process.argv[2], 'utf8', function(err, data) {
if (! err) {
fs.writeFile(process.argv[2], JSON.stringify(JSON.parse(data), null, 2), 'utf8');
}
});
@DamonOehlman
Copy link
Author

Callable with:

node node-json-prettify.js targetFile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment