AI Agent Hub
Back to skills
JSON Formatter and Validation Utility icon

JSON Formatter and Validation Utility

Development Updated 2026.08.30

Paste the following prompt into your AI chat to install this skill:

Please install @user_15292d5a/yjkj-harrylabsj-json-formatter following https://skillhub.cn/install/skillhub.md.

About this skill

What it solves

JSON logs, API responses, and config files often arrive compactly, making it easy to miss missing commas, quotes, or nesting errors. Manual reformatting can also overwrite team conventions or change apparent key order. This skill separates syntax validation from pretty-printing, which fits terminal workflows and scripted JSON checks.

Core workflow

  • Format: Use format to pretty-print JSON, with -i controlling indentation spaces (default 2) and --sort-keys sorting keys alphabetically.
  • Validate: Use validate to check syntax without emitting formatted output, useful for confirming whether a payload parses.
  • I/O: Read from a file or stdin; write to stdout by default, or to a file via -o / --output.
  • Exit codes: 0 success, 1 invalid JSON syntax, 2 missing file or permission error, and 3 other errors, which helps CI and shell scripts branch deterministically.

Limits to note

It targets standard JSON, not JSON5, comments, or JS expressions. validate does not rewrite content, and --sort-keys may change the displayed key order, so avoid it when downstream tooling depends on the original order. File mode still requires readable paths and writable output directories.

Use Cases

  • While debugging API responses, pretty-print compact JSON to two-space indentation and write it to a file.
  • In CI scripts, use validate to check service response syntax and fail on exit code 1.
  • When curating config samples, use --sort-keys to normalize key order for easier diffs.
  • Read log fragments from stdin, reformat them with format, and pass them to downstream tools.

Best For

  • Engineers troubleshooting API responses who need a quick check that JSON parses correctly.
  • Engineers maintaining CLI pipelines who need JSON validation mapped to exit codes.
  • Engineers curating config files who need consistent indentation and key ordering.
  • Engineers writing data-tooling scripts who consume and reformat JSON from stdin.