A professional command-line tool for JSON/JSONC/JSON5 validation, formatting, and inspection.
go install github.com/forgemechanic/jsonkit/cmd/jsonkit@latestOr build from source:
task cli:build
# binary is at ./bin/jsonkitValidate JSON/JSONC/JSON5 files with editor-grade diagnostics.
jsonkit validate [flags] <file>...Flags:
| Flag | Default | Description |
|---|---|---|
--profile |
auto |
Parser profile: strict, jsonc, json5, auto |
--format |
text |
Output format: text, json |
Examples:
# Validate a single file
jsonkit validate config.json
# Validate multiple files with strict profile
jsonkit validate --profile strict *.json
# Validate from stdin
echo '{"ok": true}' | jsonkit validate
# Machine-readable output
jsonkit validate --format json config.jsonProfile auto-detection from file extension:
| Extension | Profile |
|---|---|
.json |
strict |
.jsonc |
jsonc |
.json5 |
json5 |
| other | jsonc |
Format JSON files while preserving comments and semantics.
jsonkit format [flags] <file>...Flags:
| Flag | Default | Description |
|---|---|---|
--profile |
auto |
Parser profile: strict, jsonc, json5, auto |
--indent |
2 |
Indentation size (0 for compact) |
-w, --write |
false |
Write result back to source file |
--check |
false |
Check if files are formatted (exit 1 if not) |
--strip-comments |
false |
Remove all comments during formatting |
Examples:
# Format to stdout
echo '{"a":1,"b":2}' | jsonkit format
# Format in-place
jsonkit format --write config.json
# Check formatting (useful in CI)
jsonkit format --check config.json
# Compact output
jsonkit format --indent 0 config.json
# Strip comments
jsonkit format --strip-comments config.jsoncDisplay file structure, statistics, and feature usage information.
jsonkit info [flags] [file]Flags:
| Flag | Default | Description |
|---|---|---|
--profile |
auto |
Parser profile: strict, jsonc, json5, auto |
--format |
text |
Output format: text, json |
Examples:
# Show info for a file
jsonkit info config.json
# Show info from stdin
echo '{"test": [1,2,3]}' | jsonkit info
# Machine-readable output
jsonkit info --format json config.json| Flag | Default | Description |
|---|---|---|
-q, --quiet |
false |
Suppress non-essential output |
--verbose |
false |
Enable verbose output |
--color |
auto |
Colorize output: auto, always, never |
-v, --version |
Print version | |
-h, --help |
Print help |
| Code | Meaning |
|---|---|
0 |
Success |
1 |
Validation error (invalid JSON or files need formatting) |
2 |
Usage error |
3 |
Internal error |
JSONKit supports three parsing profiles:
strict– RFC 8259 compliant JSON. No comments, no trailing commas.jsonc– JSON with Comments. Allows line (//) and block (/* */) comments and trailing commas.json5– JSON5 extensions. All JSONC features plus single-quoted strings and unquoted keys.
Use --profile auto (the default) to auto-detect the profile from the file extension.