A lightweight command-line tool for formatting, validating, and minifying JSON data.
- Format JSON: Pretty-print JSON with customizable indentation
- Validate JSON: Check if JSON is valid and get detailed error messages
- Minify JSON: Remove whitespace to create compact JSON
- Color output: Syntax-highlighted JSON for better readability
- Pipe support: Works seamlessly with Unix pipes
npm install -g json-formatter-cliOr use directly with npx:
npx json-formatter-cli [options] <file>json-fmt input.jsonecho '{"name":"John","age":30}' | json-fmtjson-fmt --minify input.jsonjson-fmt --indent 4 input.jsonjson-fmt --validate input.jsonjson-fmt --no-color input.json-m, --minify- Minify JSON (remove whitespace)-i, --indent <number>- Set indentation spaces (default: 2)-v, --validate- Validate JSON without formatting--no-color- Disable syntax highlighting-h, --help- Show help--version- Show version
# Format API response
curl https://api.example.com/data | json-fmt
# Validate configuration file
json-fmt --validate config.json
# Minify for production
json-fmt --minify package.json > package.min.json
# Format with 4-space indentation
json-fmt --indent 4 data.jsonMIT