An experimental tool to modify YAMLs without losing (most of) comment lines.

yamlctl edit --set $.foo.bar=baz <input.yaml >output.yaml

Inline comments and some whitespaces are not preserved.


go install github.com/AkihiroSuda/yamlctl/cmd/[email protected]


yamlctl editable

yamlctl editable input.yaml

Prints true if the YAML is well formatted for yamlctl edit.

Misformatted YAMLs are not safely editable, but can be edited forcibly with yamlctl edit --force.

yamlctl edit

yamlctl edit --set $.foo.bar=baz <input.yaml >output.yaml

Set -w to write back the result to input.yaml directly:

yamlctl edit -w --set $.foo.bar=baz input.yaml

Set --bak to create backup files like input.yaml.bak.0, input.yaml.bak.1, …

Set --force to edit a misformatted YAML forcibly.

yamlctl query

yamlctl query $.foo.bar input.yaml

yamlctl yaml2json

yamlctl yaml2json input.yaml

Go library (yamlutil)


See the unit tests for the usage.

Similar projects


View Github