json-format-tool
Introduction
Okay, this is a tiny cli-tool for format JSON.
Usage
First install
npm i -g json-format-tool
And if we have a not pretty JSON file like this one.
We can format it.
json-format-tool demo.json
It will output
It's much pretty now.
And if you want format some mutable JSON such as HTTP request, you can use the pipe operator.
curl -X GET http://127.0.0.1:3000/my-api | json-format-tool
Other options you can check inside the cli tool.
json-format-tool -h
Usage: json-format-tool [options] <json-file> OR <output-json> | json-format-tool
Options:
-v, --version output the version number
-r, --replace replace the file directly, only works in <json-file> mode
-i, --indent <num> indent for json (default: 2)
--no-sort not need sort keys
-h, --help output usage information
Internal
Sort JSON keys based on json-stable-stringify.