A lightweight CLI tool to format and prettify JSON files.
- Pretty-print JSON with proper indentation
- Process multiple files at once
- Write formatted output back to files in-place with the
-wflag - Error handling for malformed JSON
go build -o json-prettierPrint formatted JSON to stdout:
./json-prettier file.jsonFormat multiple files:
./json-prettier file1.json file2.json file3.jsonWrite formatted JSON back to file (in-place):
./json-prettier -w file.json# View prettified JSON
./json-prettier data.json
# Format multiple files and save them
./json-prettier -w config1.json config2.json- Reads the JSON file
- Parses the JSON content
- Re-formats with 2-space indentation
- Either prints to stdout or writes back to the file (with
-wflag)
- Reports file not found errors
- Displays JSON parsing errors with context
- Handles file write permission issues