Skip to content

technicalanalysis00005-cell/json-formatter-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Formatter CLI

A lightweight command-line tool for formatting, validating, and minifying JSON data.

Features

  • 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

Installation

npm install -g json-formatter-cli

Or use directly with npx:

npx json-formatter-cli [options] <file>

Usage

Format JSON file

json-fmt input.json

Format from stdin

echo '{"name":"John","age":30}' | json-fmt

Minify JSON

json-fmt --minify input.json

Custom indentation

json-fmt --indent 4 input.json

Validate only (no output)

json-fmt --validate input.json

Disable colors

json-fmt --no-color input.json

Options

  • -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

Examples

# 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.json

License

MIT

About

A lightweight command-line tool for formatting, validating, and minifying JSON data

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages