Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.05 KB

File metadata and controls

57 lines (40 loc) · 1.05 KB

jsonfmt

Fast JSON formatter and validator for the command line. Written in Go for speed — handles large files without breaking a sweat.

Install

go install github.com/himalaya0x/jsonfmt@latest

Or build from source:

git clone https://github.com/himalaya0x/jsonfmt.git
cd jsonfmt
go build -o jsonfmt .

Usage

# Format a file
jsonfmt data.json

# Format from stdin
cat data.json | jsonfmt
curl -s https://api.example.com/data | jsonfmt

# Validate only (no output, exit code 0 or 1)
jsonfmt --validate data.json

# Compact (remove whitespace)
jsonfmt --compact data.json

# Custom indent
jsonfmt --indent 4 data.json

# In-place formatting
jsonfmt --write data.json

# Sort keys
jsonfmt --sort data.json

Features

  • Formats and validates JSON from files or stdin
  • Compact mode for minification
  • In-place file editing with --write
  • Alphabetical key sorting
  • Configurable indentation (default: 2 spaces)
  • Fast — processes 100MB+ files in under a second
  • Zero dependencies beyond the Go standard library

License

MIT