Where to start First steps track · 15 stages
Linux Labs

YAML validator, JSON converter

YAML validation with the error's place and cause, and a YAML ⇄ JSON converter.

Direction
Indent
Result

    

Paste YAML or pick an example

Calculated in your browser — nothing is sent to the server

Practice on a machine

Lab “Repair a persistent address”

easy ~25 min stage 3 of the “Networking” track

Open the lab

In a Linux terminal

bash
yamllint docker-compose.yml # indentation, tabs, duplicate keys docker compose config # check a compose file sudo netplan try # apply netplan, roll back after 120 s cloud-init schema --config-file user-data # check a cloud-config yq -o=json '.' config.yaml # YAML to JSON (Mike Farah's yq)

Keep in mindYAML indents with spaces only: a tab is an error, and one space off moves a key to another level.

FAQ

Why does netplan say “Invalid YAML” when everything looks aligned?

Most often it is a tab in the indentation or keys of one level indented differently: paste the file here and the line lights up. Then run sudo netplan generate.

What is the difference between YAML 1.1 and 1.2?

In 1.1 (PyYAML, Ansible, netplan), yes, no, on, off are booleans and 0755 is octal; in 1.2 they are strings and a decimal number. Quote such values.

How do I convert YAML to JSON?

Paste the YAML and the JSON appears on the right. Comments are dropped, and anchors & and aliases * expand into full values.

Loading…