jfmt-cli
v1.0.0
Published
Pretty-print JSON from the command line or pipe
Maintainers
Readme
jfmt-cli
Pretty-print JSON from the command line. With colors.
Install
npm install -g jfmt-cliUsage
# From a string
json-fmt '{"name":"test","count":42}'
# From a file
json-fmt package.json
# From a pipe
echo '{"a":1}' | json-fmt
curl -s api.github.com/users/octocat | json-fmt
# Shorthand alias
echo '{"a":1}' | jfOptions
-i, --indent <n> Indentation spaces (default: 2)
-c, --compact Compact output (no indentation)
-m, --minify Minify (same as --compact)
--no-color Disable colors
-h, --help Show helpExamples
# Custom indentation
json-fmt data.json --indent 4
# Minify
json-fmt data.json --minify
# Pipe from curl
curl -s https://api.github.com/users/octocat | json-fmt
# Combine with other tools
cat large.json | json-fmt | head -50Colors
Output is colorized when writing to a terminal:
- Keys: cyan
- Strings: green
- Numbers: yellow
- Booleans: magenta
- Null: gray
Use --no-color to disable.
License
MIT
