json-formatter-pro

v1.0.3

Format and validate JSON files with options for indentation, key sorting, input/output from files or stdin, and detailed error reporting.

0· 304· 4 versions· 0 current· 0 all-time· Updated 14h ago· MIT-0
byhaidong@harrylabsj

Install

openclaw skills install harrylabsj-json-formatter

json-formatter-pro

Format and validate JSON files with pretty-printing and validation modes.

Description

A utility skill for formatting JSON files with proper indentation and validating JSON syntax. Supports reading from files or stdin, outputting to files or stdout.

Usage

# Format a JSON file (pretty-print to stdout)
python ~/.openclaw/skills/json-formatter/json_formatter.py format input.json

# Format and save to a new file
python ~/.openclaw/skills/json-formatter/json_formatter.py format input.json -o output.json

# Validate JSON syntax without formatting
python ~/.openclaw/skills/json-formatter/json_formatter.py validate input.json

# Read from stdin, format and output to stdout
cat input.json | python ~/.openclaw/skills/json-formatter/json_formatter.py format -

# Validate JSON from stdin
cat input.json | python ~/.openclaw/skills/json-formatter/json_formatter.py validate -

Options

  • format: Pretty-print JSON with proper indentation
  • validate: Check if JSON is valid without formatting output
  • -o, --output: Specify output file (default: stdout)
  • -i, --indent: Number of spaces for indentation (default: 2)
  • --sort-keys: Sort JSON keys alphabetically

Examples

# Format with 4-space indentation
python ~/.openclaw/skills/json-formatter/json_formatter.py format data.json -i 4

# Format and sort keys
python ~/.openclaw/skills/json-formatter/json_formatter.py format data.json --sort-keys

# Validate a JSON file
python ~/.openclaw/skills/json-formatter/json_formatter.py validate config.json
# Output: Valid JSON or error message with line number

Exit Codes

  • 0: Success
  • 1: Invalid JSON syntax
  • 2: File not found or permission error
  • 3: Other error

Version tags

latestvk97bdw67x77yk89jbtfz01vpkx83anw2