Comments YAML has, JSON doesn't
YAML supports # for line comments. Everything from # to end-of-line is ignored. Comments are not part of the data model — round-tripping with most parsers loses them. (Use ruamel.yaml in Python if comment preservation matters.)
Multi-document files
One file can contain multiple YAML documents, separated by --- on its own line. The end-of-document marker ... is rare but valid. Multi-document files are how Kubernetes ships a Deployment + Service + ConfigMap as one kubectl apply -f target.
Reading multi-document YAML
Most parsers expose a stream/iterator API. PyYAML: yaml.safe_load_all(text). js-yaml: yaml.loadAll(text). yq: yq 'select(.kind == "Service")' multi.yaml.
Principle: use comments to capture the why that the data shape doesn't carry — links to incidents, defaults, when this value should change. Don't restate what the keys already say.
# server port next to port: 8000 is noise; # keep below 1024 only on the auth gateway, see RFC-12 is signal.