@lxgicstudios/json-to-yaml
v1.0.0
Published
Bidirectional JSON to YAML converter. Pipe-friendly CLI with sort-keys and indent options. Convert config files instantly. Free CLI tool.
Maintainers
Readme
json-to-yaml
Bidirectional JSON/YAML converter that works from the command line. Pipe-friendly, auto-detects format, and lets you sort keys and control indentation. One dependency (js-yaml).
Install
npm install -g @lxgicstudios/json-to-yamlOr run directly:
npx @lxgicstudios/json-to-yaml config.jsonFeatures
- Auto-detect input format (JSON or YAML) and convert to the other
- Force direction with
--to-yamlor--to-json - Pipe-friendly (reads from stdin)
- Sort keys alphabetically with
--sort-keys - Custom indentation with
--indent - Write to file with
--output - Compact YAML output with
--compact - Works with deeply nested structures
Usage
Auto-detect and convert
json-to-yaml config.json # outputs YAML
json-to-yaml config.yaml # outputs JSONPipe from stdin
cat data.json | json-to-yaml
echo '{"name": "test"}' | json-to-yaml
curl -s https://api.example.com/data | json-to-yamlSort keys
json-to-yaml --sort-keys package.jsonCustom indent
json-to-yaml --indent 4 config.jsonSave to file
json-to-yaml config.json -o config.yaml
json-to-yaml docker-compose.yml -o docker-compose.jsonOptions
| Option | Alias | Default | Description |
|--------|-------|---------|-------------|
| --help | -h | | Show help message |
| --to-yaml | -y | | Force JSON to YAML conversion |
| --to-json | -j | | Force YAML to JSON conversion |
| --sort-keys | -s | | Sort object keys alphabetically |
| --indent | -i | 2 | Indentation level |
| --output | -o | | Write output to file |
| --compact | | | Use compact/flow YAML style |
| --no-color | | | Disable colored output |
License
MIT - LXGIC Studios
