Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🩺 json-doctor

Validate, inspect and fix JSON — from the terminal, instantly.

CI License Go Deps Tests

validate · pretty / minify · stats · dot-path queries


✨ Features

  • ✅ Validation with location--explain shows 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 queriesusers.0.name, array indexes included
  • 🪶 Pure stdlib — zero dependencies, single ~2 MB binary
  • 🔁 Unix-friendly — reads stdin or file, pipes anywhere

🚀 Quick Start

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

📖 Usage

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

Examples

$ 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

🧱 Tech Stack

Layer Tech
Language Go 1.27 (stdlib only)
Testing go test
Packaging Docker (multi-stage)
CI GitHub Actions

Built with ⚡ by v01dst

GitHub Discord

About

JSON toolkit — validate with line/column errors, pretty/minify, structural stats, dot-path queries

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages