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 the command line

First, Install yamllint

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

you can validate these files using

yamllint input.yaml

In Python, the pyyaml package provides 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 the console

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

YAML validator with IDE

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

There is a popular code IDE available.

  • Visual Studio : Open source popular editor for popular languages, There are a lot of plugins for YAML linter extensions, You can use red hat 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 IntelliJ editor

yaml validator online tools

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