YAML to JSON, and back
YAML is parsed as YAML 1.2. Anchors and aliases are expanded, comments are dropped (JSON has none) and a stream of several documents becomes a JSON array.
defaults: &d
retries: 3
job:
settings: *d
name: sync
{ "defaults": { "retries": 3 }, "job": { "settings": { "retries": 3 }, "name": "sync" } }Switch to JSON → YAML for the other direction, or press Swap to feed the output back as input. Because YAML 1.2 is a superset of JSON, that direction loses nothing.
Things that surprise people in YAML
- Indentation is structure, and tabs are not allowed for it. A stray tab is the most common parse error.
version: 1.10is the number 1.1. Quote values that must stay text.- In YAML 1.1 parsers,
no,onandoffare booleans (the "Norway problem"). Here they are strings, per YAML 1.2. - A value containing
:or starting with*,&or@needs quotes.
The JSON side can be checked in the JSON validator.