YAML vs JSON — when to use which
YAML is a superset of JSON — every JSON document is valid YAML. YAML adds: comments, multi-line strings, anchors/aliases for reuse, and fewer mandatory quotes. Win for: Kubernetes/Helm, CI configs (GitHub Actions, GitLab), OpenAPI specs, human-edited application configs.
JSON wins for: API wire format, inter-language data exchange, browser fetches, anything where speed/simplicity of parsing matters more than editor ergonomics.
YAML indentation gotchas
YAML's biggest footgun: tabs are forbidden. Indentation must be spaces. Mixing tabs and spaces produces
a parse error that can be hard to spot. Set your editor to "tabs → spaces" for .yml files.
Common YAML types you'll see in configs
- Scalar values — strings, numbers, booleans, null. Quotes optional for most strings.
- Block mappings —
key: valuepairs, indented. - Block sequences — lines starting with
-. - Flow mappings —
{a: 1, b: 2}JSON-like inline form. - Anchors & aliases —
&namedefines,*namereuses. Used for DRY configs. - Multi-line strings —
|preserves newlines,>folds them.
FAQ
Does round-tripping preserve comments?
No. JSON has no comments, so YAML → JSON → YAML loses them. This is a fundamental JSON limitation, not a bug in the converter.
Why did my number turn into a string?
YAML 1.1 vs 1.2 differs on boolean parsing. Strings like yes, no, on, off are booleans in YAML 1.1 but strings in 1.2. This tool uses 1.2. Quote ambiguous strings explicitly.
Is this safe for untrusted input?
Yes. We use js-yaml's load() which is safe-load by default in v4+. It does not evaluate custom tags that could execute code.
Related tools
- JSON Formatter — Format, validate, and beautify JSON online. 100% client-side — your data never leaves your browser.
- XML Formatter — Format, validate, and beautify XML documents.
- CSV to JSON Converter — Convert CSV files to JSON with proper quoting and escaping.
- JSON Diff — Compare two JSON objects structurally with field-by-field diff.
Pillar
Part of Data & Format — JSON, YAML, XML, CSV, SQL, Markdown.
Written by Mian Ali Khalid. Last updated 2026-04-25.