YAML and JSON both structure data, and either can technically represent the same underlying information — in fact, valid JSON is actually valid YAML too, since YAML was designed as a superset. The real-world choice between them for something like a configuration file comes down to a genuine, specific tradeoff: how easy the file is for a human to write and read by hand, versus how strict and universally parseable it is.
YAML: designed to be readable and hand-writable
YAML uses indentation and minimal punctuation to represent structure, closer in spirit to how someone might naturally write out a structured list by hand than JSON's brackets-and-quotes syntax. This makes YAML files noticeably easier for a person to read at a glance and, more importantly, easier to write and edit by hand without constantly worrying about matching brackets or misplaced commas — a genuine practical advantage for configuration files, which humans very often need to open and manually adjust.
JSON: stricter syntax, universally parseable
JSON's explicit brackets, quotes, and commas make its structure completely unambiguous to a parser — there's no whitespace-sensitivity to worry about, no indentation level that could accidentally shift meaning. This strictness is a genuine advantage for automated, programmatic contexts: JSON is simpler and more universally supported to parse reliably across virtually every programming language, with less room for a subtle formatting mistake to silently change what the data means.
Where YAML's readability becomes a real risk
YAML's reliance on indentation for structure is exactly what makes it pleasant to write by hand, but it's also a genuine source of subtle bugs — an incorrectly indented line can silently change the meaning of a YAML file in a way that's not always obvious just by glancing at it, unlike JSON's more explicit, less whitespace-dependent structure. This is a real, well-known practical downside that comes directly from the same feature that makes YAML nicer to write in the first place.
Why configuration files specifically lean toward YAML
Configuration files are very often written and edited directly by a person, sometimes without specialized tooling to catch a syntax error before it causes a problem, which is exactly the context where YAML's more natural, readable syntax pays off most, despite its indentation-sensitivity risk. Many well-known tools and platforms have adopted YAML specifically for configuration for this reason — the tradeoff of accepting some indentation risk in exchange for a considerably more pleasant hand-editing experience is one the configuration-file use case is generally happy to make.
A practical way to decide
For configuration files primarily written and edited by hand, where human readability and ease of editing matter most: YAML is the more common and generally more pleasant choice, as long as you're careful with indentation (or use an editor that helps catch mistakes). For data primarily generated and consumed programmatically, where a person rarely needs to hand-edit the file directly and strict, unambiguous parsing matters more: JSON's stricter syntax reduces the risk of a subtle formatting error changing the data's meaning.
If a configuration or data file needs to become a readable, shareable document rather than staying as machine-parsed data, TXT to PDF can turn an exported or summarized version into a properly formatted document once the raw configuration data isn't the point anymore.