yaml-to-json-cli
v1.0.0
Published
Convert YAML to JSON and JSON to YAML from the command line
Maintainers
Readme
yaml-to-json-cli
Convert YAML to JSON and JSON to YAML from the command line.
Install
npm install -g yaml-to-json-cliUsage
# YAML -> JSON
yaml2json yaml2json config.yaml
yaml2json yaml2json config.yaml -o config.json --pretty
yaml2json yaml2json config.yaml --sort-keys --indent 4
# JSON -> YAML
yaml2json json2yaml data.json
yaml2json json2yaml data.json -o data.yaml
# Read from stdin
cat config.yaml | yaml2json yaml2json --stdin
echo '{"a":1}' | yaml2json json2yaml --stdin
# Validate only (no output)
yaml2json yaml2json config.yaml --validate
yaml2json json2yaml data.json --validate
# Batch: convert all files in a directory
yaml2json yaml2json ./configs/
yaml2json json2yaml ./data/Options
| Option | Description |
|---|---|
| -o, --output <path> | Write output to file |
| --pretty | Pretty-print JSON |
| --indent <n> | Indentation spaces (default: 2) |
| --sort-keys | Sort object keys alphabetically |
| --stdin | Read input from stdin |
| --validate | Check syntax only, no conversion |
License
MIT
