JSON Swiss Army Knife — Format, minify, and convert JSON to .env or YAML from the command line.
npm install -g json-fmt# Format JSON (pretty print)
echo '{"name":"test","value":123}' | json-fmt
# Minify JSON
echo '{"name":"test","value":123}' | json-fmt --minify
# Convert JSON to .env
echo '{"name":"test","value":123}' | json-fmt --to-env
# Convert JSON to YAML
echo '{"name":"test","value":123}' | json-fmt --to-yaml
# Custom indent (2 or 4)
echo '{"a":1}' | json-fmt -i 4| Flag | Description |
|---|---|
-f, --format |
Format JSON (default) |
-m, --minify |
Minify JSON |
--to-env |
Convert JSON to .env format |
--to-yaml |
Convert JSON to YAML |
-i, --indent |
Indentation (2 or 4) |
-h, --help |
Show help |
json-fmt data.json
json-fmt data.json --minify > data.min.jsoncurl -s https://api.example.com/data | json-fmt | jq '.data'MIT