Skip to content

Instantly share code, notes, and snippets.

@jmealo
Created May 25, 2015 23:01
Show Gist options
  • Save jmealo/78031e38cb94830ef400 to your computer and use it in GitHub Desktop.
Save jmealo/78031e38cb94830ef400 to your computer and use it in GitHub Desktop.
JSON prettifier for the terminal, just pipe to stdin and it'll output formatted JSON
#!/usr/bin/env node
var stdin = process.openStdin();
var data = "";
stdin.on('data', function(chunk) {
data += chunk;
});
stdin.on('end', function() {
var json;
try {
json = JSON.parse(data);
} catch (e) {
console.error(e);
process.exit(1);
}
console.log(JSON.stringify(json, null, ' '));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment