YAML Basics/Parse YAML with Python

Quickly verify that a YAML file loads successfully.

Section: Validate and inspect YAML from the terminal

Parse YAML with Python

bash
bash
python - <<'PY'
import yaml
with open('config.yaml') as f:
    print(yaml.safe_load(f))
PY
Explanation

Useful when you already have Python and PyYAML available and want a fast sanity check.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Validate and inspect YAML from the terminal
Validate Kubernetes YAML client-side
Check whether a manifest parses before applying it.
OpenIn sheetbashsame section
Lint a YAML file
Check a file for syntax and style problems.
OpenIn sheetbashsame section
Pretty-print YAML with yq
Read and normalize YAML output from the command line.
OpenIn sheetbashsame section
Simple mapping
Define key-value pairs in YAML.
OpenIn sheetyaml1 tag match
Simple sequence
Represent ordered lists with dashes.
OpenIn sheetyaml1 tag match
Nested mapping and list
Combine objects and arrays in one document.
OpenIn sheetyaml1 tag match