September 18, 2012

JSON format command line utility

Very often I need to format a single-line JSON, so I can read it easily.

Even though modern browser developer tools do it nicely with server responses in preview tab, I want to be able to do something similar with local files.

Node.js has a very good API to work both with JSON and file system. So I created this simple command line utility in CoffeeScript. It accepts the input file name as a 1st parameter and the output file as an optional 2nd parameter. If the output file name is undefined, it writes the result to the console.

No comments: