Validate, inspect and fix JSON — from the terminal, instantly.
validate · pretty / minify · stats · dot-path queries
- ✅ Validation with location —
--explainshows the exact line and column of syntax errors - 💅 Pretty / minify — 2-space reformat or whitespace-strip in one pass
- 📊 Structural stats — key counts, max depth, type histogram, entropy for your JSON
- 🔎 Dot-path queries —
users.0.name, array indexes included - 🪶 Pure stdlib — zero dependencies, single ~2 MB binary
- 🔁 Unix-friendly — reads stdin or file, pipes anywhere
git clone https://github.com/v01dst/json-doctor
cd json-doctor
go build -o json-doctor .Or with Docker:
docker build -t json-doctor .
docker run --rm -i json-doctor --pretty < data.jsonjson-doctor [flags] [file.json] (stdin if no file)
--pretty reformat with 2-space indent
--minify strip all whitespace
--stats structural statistics
-q PATH dot-path query (users.0.name)
--explain on error, print line/column
--version print version
$ echo '{"name":"ada","langs":["go","py"]}' | json-doctor --pretty
{
"name": "ada",
"langs": [
"go",
"py"
]
}
$ echo '{"broken": tru}' | json-doctor --explain
error: invalid character '}' in literal true (expecting 'e') (line 1, column 16)
$ json-doctor -q users.0.email data.json
"ada@example.com"
$ json-doctor --stats big.json
{
"keys": 3,
"maxDepth": 4,
"arrays": 1,
...
}| Exit code | Meaning |
|---|---|
0 |
Success |
1 |
Invalid JSON / bad query |
| Layer | Tech |
|---|---|
| Language | Go 1.27 (stdlib only) |
| Testing | go test |
| Packaging | Docker (multi-stage) |
| CI | GitHub Actions |