{"skill":{"slug":"config-format-converter","displayName":"Config Format Converter","summary":"Convert and validate configuration files between JSON, YAML, and TOML formats. Use when working with config files that need format conversion, syntax validat...","description":"---\nname: config-format-converter\ndescription: Convert and validate configuration files between JSON, YAML, and TOML formats. Use when working with config files that need format conversion, syntax validation, or pretty-printing. Supports package.json, pyproject.toml, .yaml/.yml configs, and any structured data files. Ideal for cross-platform project setup, CI/CD config migration, and developer tooling workflows.\n---\n\n# Config Format Converter\n\nUniversal configuration file format converter for JSON, YAML, and TOML.\n\n## When to Use\n\n- Converting `package.json` to `pyproject.toml` or vice versa\n- Migrating CI/CD configs between formats (`.yaml` ↔ `.json`)\n- Normalizing config files for cross-platform projects\n- Validating syntax before committing config changes\n- Pretty-printing minified config files\n\n## Supported Formats\n\n| Format | Extensions | Use Cases |\n|--------|-----------|-----------|\n| JSON | `.json` | npm, Node.js, VS Code settings |\n| YAML | `.yaml`, `.yml` | Docker Compose, GitHub Actions, Kubernetes |\n| TOML | `.toml` | Python Poetry, Rust Cargo, Go modules |\n\n## Quick Start\n\n### Convert Between Formats\n\n```python\nimport json\nimport yaml\nimport toml\n\n# JSON to YAML\nwith open('package.json') as f:\n    data = json.load(f)\nwith open('package.yaml', 'w') as f:\n    yaml.dump(data, f, default_flow_style=False, sort_keys=False)\n\n# YAML to JSON\nwith open('docker-compose.yaml') as f:\n    data = yaml.safe_load(f)\nwith open('docker-compose.json', 'w') as f:\n    json.dump(data, f, indent=2)\n\n# TOML to JSON\nwith open('pyproject.toml') as f:\n    data = toml.load(f)\nwith open('pyproject.json', 'w') as f:\n    json.dump(data, f, indent=2)\n```\n\n### Validate Config Syntax\n\n```python\nimport json\nimport yaml\n\ndef validate_json(filepath):\n    try:\n        with open(filepath) as f:\n            json.load(f)\n        return True, \"Valid JSON\"\n    except json.JSONDecodeError as e:\n        return False, str(e)\n\ndef validate_yaml(filepath):\n    try:\n        with open(filepath) as f:\n            yaml.safe_load(f)\n        return True, \"Valid YAML\"\n    except yaml.YAMLError as e:\n        return False, str(e)\n```\n\n### Pretty-Print Configs\n\n```python\nimport json\n\n# Compact to pretty JSON\nwith open('config.min.json') as f:\n    data = json.load(f)\nwith open('config.json', 'w') as f:\n    json.dump(data, f, indent=2, ensure_ascii=False)\n```\n\n## Common Workflows\n\n### Migrate npm Project to Python Poetry\n\n```python\nimport json\nimport toml\n\n# Read package.json\nwith open('package.json') as f:\n    pkg = json.load(f)\n\n# Create pyproject.toml structure\npyproject = {\n    'tool': {\n        'poetry': {\n            'name': pkg.get('name', ''),\n            'version': pkg.get('version', '0.1.0'),\n            'description': pkg.get('description', ''),\n            'authors': [],\n            'dependencies': {}\n        }\n    }\n}\n\n# Write TOML\nwith open('pyproject.toml', 'w') as f:\n    toml.dump(pyproject, f)\n```\n\n### Convert Docker Compose YAML to JSON for CI\n\n```python\nimport yaml\nimport json\n\nwith open('docker-compose.yaml') as f:\n    compose = yaml.safe_load(f)\n\nwith open('docker-compose.json', 'w') as f:\n    json.dump(compose, f, indent=2)\n```\n\n## Best Practices\n\n- **Preserve comments**: YAML/TOML comments are lost in conversion; document important notes separately\n- **Key ordering**: Use `sort_keys=False` to preserve original key order\n- **Unicode**: Always use `ensure_ascii=False` for international configs\n- **Validation**: Always validate output after conversion\n- **Backup**: Keep original files before bulk conversion\n\n## Error Handling\n\nCommon issues and solutions:\n\n| Issue | Cause | Fix |\n|-------|-------|-----|\n| `ScannerError` | Invalid YAML syntax | Check indentation (spaces, not tabs) |\n| `TomlDecodeError` | Invalid TOML syntax | Verify section headers `[section]` |\n| `JSONDecodeError` | Trailing commas in JSON | Remove commas before `}` or `]` |\n| Unicode errors | Encoding mismatch | Open files with `encoding='utf-8'` |\n\n## Dependencies\n\n```bash\npip install pyyaml toml\n```\n","tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":197,"installsAllTime":0,"installsCurrent":0,"stars":0,"versions":1},"createdAt":1772536715548,"updatedAt":1778491699946},"latestVersion":{"version":"1.0.0","createdAt":1772536715548,"changelog":"Initial release - Auto-generated by OpenClaw","license":null},"metadata":null,"owner":{"handle":"leonardodpanda","userId":"s177dprky1s69vgjk3rvag5yyh884gga","displayName":"LeonardoDpanda","image":"https://avatars.githubusercontent.com/u/51777214?v=4"},"moderation":null}