examples/json-formatter

Format JSON files with configurable indentation and key sorting.

Updated Dec 30, 2025
One-click install
npx skills add https://github.com/while-basic/enact-template --skill examples-json-formatter
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: examples/json-formatter
Source: https://github.com/while-basic/enact-template/tree/main/examples/tools/json-formatter
Command: npx skills add https://github.com/while-basic/enact-template --skill examples-json-formatter

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

JSON datasets and configs often require consistent formatting for readability and tooling. This Skill formats JSON files across nested directories, applying a configurable indentation and optional key sorting, saving results to an output folder.

Core Features & Use Cases

  • Flexible formatting: apply indentation and optional key sorting to all JSON files under /input.
  • Directory-preserving: preserves the original directory structure in /output for easy mapping back to source files.
  • Use case: format a large set of JSON configuration files for a CI pipeline, generating consistently formatted configs for reviews.

Quick Start

Use the json-formatter tool to format JSON files located under /input and write results to /output. Example commands:

  • enact run ./examples/tools/json-formatter --input ./data --output ./formatted
  • enact run ./examples/tools/json-formatter --input ./data --output ./formatted --input indent=4
  • enact run ./examples/tools/json-formatter --input ./data --output ./formatted --input sort_keys=true
  • enact run ./examples/tools/json-formatter --input ./src --output ./src --apply

Frequently Asked Questions about examples/json-formatter

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I format multiple JSON files across nested directories at once?

To format JSON files across nested directories, the tool processes all files under an input folder and writes consistently indented results to an output folder. It preserves the original directory structure, allowing you to easily map formatted outputs back to their source files.

Can I sort JSON keys and change indentation when formatting configuration files?

Yes, you can format JSON configuration files with configurable indentation and optional key sorting. The tool accepts specific parameters to set indentation width and enable alphabetical key sorting, ensuring consistently formatted configs for CI pipelines and reviews.

Does this JSON formatter require any external services or dependencies?

No external services are required to format JSON files. The solution runs entirely on Python 3.12 using an internal formatting script, allowing you to execute the process locally without connecting to external APIs or installing third-party dependencies.

What is the best way to apply consistent indentation to a large set of JSON files?

The best way to apply consistent indentation to large JSON datasets is using an automated script that reads from an input directory and writes formatted files to an output directory. This ensures uniform readability across all configuration files without manual editing.

Can I overwrite original JSON files in place instead of writing to a new directory?

Yes, you can overwrite original JSON files in place by setting the input and output directories to the same path and applying the changes directly. This modifies the source files with the new indentation and sorting configuration without creating duplicates.