home / skills / aidotnet / moyucode / json-yaml-converter

json-yaml-converter skill

/skills/tools/json-yaml-converter

This skill converts between JSON, YAML, and TOML, validates and formats configuration files to ensure consistency and readability.

npx playbooks add skill aidotnet/moyucode --skill json-yaml-converter

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
1005 B
---
name: json-yaml-converter
description: 在JSON、YAML和TOML格式之间转换,验证和格式化配置文件。
metadata:
  short-description: 转换JSON/YAML/TOML格式
source:
  repository: https://github.com/yaml/pyyaml
  license: MIT
---

# JSON/YAML Converter Tool

## Description
Convert between JSON, YAML, and TOML formats with validation and formatting.

## Trigger
- `/convert-config` command
- User requests format conversion
- User needs to validate JSON/YAML

## Usage

```bash
# Convert JSON to YAML
python scripts/json_yaml_converter.py convert --input config.json --output config.yaml

# Convert YAML to JSON
python scripts/json_yaml_converter.py convert --input config.yaml --output config.json

# Validate file
python scripts/json_yaml_converter.py validate --input config.yaml

# Format/prettify
python scripts/json_yaml_converter.py format --input config.json --indent 2
```

## Tags
`json`, `yaml`, `toml`, `config`, `convert`

## Compatibility
- Codex: ✅
- Claude Code: ✅

Overview

This skill converts configuration files between JSON, YAML, and TOML, and offers validation and formatting (prettify) utilities. It streamlines config workflows by ensuring syntactic correctness and consistent indentation across formats. Use it to quickly transform files for different tools or to validate user-provided configs before deployment.

How this skill works

The tool accepts an input file and target format, parses the source using robust parsers for JSON, YAML, and TOML, then serializes the data into the requested format while preserving structure and basic types. It also supports standalone validation to detect syntax errors and a formatting option to apply consistent indentation and style. Commands can be run via a CLI trigger to convert, validate, or prettify files.

When to use it

  • Converting a config file to a different format required by a tool or library.
  • Validating user-supplied JSON/YAML/TOML before applying or committing changes.
  • Standardizing indentation and style across multiple configuration files.
  • Quickly inspecting a file by converting it to a more readable format.
  • Automating format conversion in scripts or CI pipelines.

Best practices

  • Validate the source file before converting to catch syntax errors early.
  • Keep backups or use version control when performing batch conversions.
  • Choose a consistent indentation (2 or 4 spaces) and apply via the format command.
  • When converting between formats, review type-sensitive fields (dates, nulls) for semantic changes.
  • Integrate validation into CI to prevent malformed configs from deploying.

Example use cases

  • Convert a project's config.json to config.yaml so a YAML-only tool can consume it.
  • Validate a complex Helm values file (YAML) before a Kubernetes deployment.
  • Prettify a minified JSON config to make debugging easier.
  • Automate converting TOML config from a Rust project into JSON for a JavaScript service.
  • Run a validation step in CI to block merges with invalid YAML or JSON.

FAQ

Will data types always remain identical after conversion?

Most basic types (strings, numbers, booleans, arrays, objects) are preserved, but some formats handle dates, binary, or null values differently—inspect sensitive fields after conversion.

Can I set indentation or style options?

Yes, the formatter accepts indentation settings (for example, --indent 2) so you can enforce project style conventions.