https://github.com/ddebin/yaml-sort
CLI tool to sort YAML files alphabetically
https://github.com/ddebin/yaml-sort
cli nodejs sort stream yaml yml
Last synced: 29 days ago
JSON representation
CLI tool to sort YAML files alphabetically
- Host: GitHub
- URL: https://github.com/ddebin/yaml-sort
- Owner: ddebin
- License: mit
- Created: 2020-06-18T07:58:36.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-09T19:50:25.000Z (5 months ago)
- Last Synced: 2025-04-02T08:48:56.834Z (about 1 month ago)
- Topics: cli, nodejs, sort, stream, yaml, yml
- Language: JavaScript
- Homepage:
- Size: 64.5 KB
- Stars: 25
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://www.npmjs.com/package/yaml-sort)# About
`yaml-sort` sorts [YAML](https://yaml.org/) files alphabetically.
This tool is basically a tiny wrapper around [js-yaml](https://github.com/nodeca/js-yaml).
(Inspired by [yml-sorter](https://github.com/42BV/yml-sorter))
# Installation
`npm install -g yaml-sort`
# Usage
```
Usage: yaml-sort [options]Options:
-i, --input The YAML file(s) which needs to be sorted [array] [default: STDIN]
-o, --output The YAML file to output sorted content to [string] [default: overwrite input file if specified or STDOUT]
-s, --stdout Output the proposed sort to STDOUT only [boolean]
-k, --check Check if the given file(s) is already sorted [boolean]
--indent, --id Indentation width (in spaces) [number] [default: 2]
-e, --encoding Input encoding [choices: "ascii", "utf8", "utf16le"] [default: "utf8"]
-q, --quotingStyle Strings will be quoted using this quoting style [choices: "single", "double"] [default: "single"]
-f, --forceQuotes Force quotes for all scalar values [boolean] [default: false]
-w, --lineWidth Wrap line width (-1 for unlimited width) [number] [default: 80]
-h, --help Show help [boolean]
--version Show version number [boolean]Examples:
yaml-sort --input config.yml Sorts alphabetically and overwrites the file config.yml
yaml-sort --input config.yml --lineWidth 100 --stdout Sorts the file config.yml and output result to STDOUT wrapped to 100 columns
yaml-sort --input config.yml --indent 4 --output sorted.yml Indents with 4 spaces and outputs result to file sorted.yml
yaml-sort --input config.yml --forceQuotes --quotingStyle double Forces double quotes for all scalar values
cat config.yml | yaml-sort Sorts alphabetically from STDIN
```