Skip to content

Instantly share code, notes, and snippets.

@kristopherjohnson
kristopherjohnson / formatjson.js
Last active Apr 17, 2022
Read JSON from standard input and writes formatted JSON to standard output. Requires Node.js.
View formatjson.js
#!/usr/bin/env node
// Reads JSON from stdin and writes equivalent
// nicely-formatted JSON to stdout.
var stdin = process.stdin,
stdout = process.stdout,
inputChunks = [];
stdin.resume();