JSON Formatter and Validation Utility
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
formatto pretty-print JSON, with-icontrolling indentation spaces (default 2) and--sort-keyssorting keys alphabetically. - Validate: Use
validateto 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:
0success,1invalid JSON syntax,2missing file or permission error, and3other 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.
Related Skills
A one-shot coding agent built on Claude Code CLI that runs non-interactively, supports a specified workdir, and can be monitored in the foreground or background.
Preview and confirm file sorting by extension, with recursive cleanup, ignore rules, and transactional rollback.
An engineering assistant for static HTML/CSS/JS pages, design-token extraction, IE8-compatible review, and structured delivery.
An engineering workflow for requirement analysis, scenario modeling, risk planning, quality gates, testing, and knowledge capture, with lightweight, standard, and full modes.