yaml file validation is one important to check for the correctness of yaml file content and syntax rules for the yaml file format.

yaml validator checks validation for

  • Syntax rules for content
  • format yaml content
  • Check errors for a node that has a valid key, not found, valid child nodes
  • Auto completion
  • auto-indentation

Usually, There are a lot of linter programs available to check for validation of the yaml file. There are many ways to check yaml file validation

Command line to install and check yaml validator

yamllint is one of the programs to check via command line

First, Install yamllint

sudo apt-get install yamllint // ubuntu
sudo dnf install yamllint // Linux

you can validate the yaml file using

yamllint input.yaml

In python, the pyyaml package provides yaml validation with yamllint.

Here is a command to install the package

pip install --user yamllint

using the python command, we can validate and print the validation logs to console

python -c 'import yaml, sys; print(yaml.safe_load(sys.stdin))' < input.yaml

YAML validator ith IDE

IDE is a popular code editor to write and validate the code

There is a popular code IDE available.

  • Visual studio : Opensource popular editor for popular languages, There are a lot of plugins for yaml linter extensions, You can use redhat yaml
  • Eclipse : popular editor for java and python , yaml-editor can be used for yaml validation
  • Intelli IDE: yaml plugin provides yaml language support in Intelli editor

yaml validator online tools

There are various multiple online tools, One of them yaml validation online