jsonkit

command module
v0.0.0-...-2f150ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

README

JSONKit CLI

A professional command-line tool for JSON/JSONC/JSON5 validation, formatting, and inspection.

Installation

go install github.com/forgemechanic/jsonkit/cmd/jsonkit@latest

Or build from source:

task cli:build
# binary is at ./bin/jsonkit

Commands

jsonkit validate

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

Profile auto-detection from file extension:

Extension Profile
.json strict
.jsonc jsonc
.json5 json5
other jsonc
jsonkit format

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.jsonc
jsonkit info

Display 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

Global Flags

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

Exit Codes

Code Meaning
0 Success
1 Validation error (invalid JSON or files need formatting)
2 Usage error
3 Internal error

Profiles

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.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL