JSON vs YAML

JSON and YAML both represent the same kinds of structured data — objects, arrays, scalars — but with very different ergonomics. JSON uses braces and quotes and is unforgiving; YAML uses indentation and reads more like prose, which is why it dominates config files.

The catch is that YAML's flexibility invites subtle bugs, especially around whitespace and implicit typing. JSON's strictness is annoying to hand-write but rock-solid for machines. Most stacks use both.

At a glance

AspectJSONYAML
SyntaxBraces, brackets, quotesIndentation, minimal punctuation
CommentsNot supportedSupported with #
WhitespaceInsignificantSignificant — indentation matters
Human editingFiddlyComfortable
Best forAPIs, data interchangeConfig files, CI pipelines

When to use JSON

  • You're sending data over an API or between services.
  • You want a format every language parses identically.
  • Strictness and no ambiguity matter more than readability.

When to use YAML

  • You're writing config a human will read and edit often.
  • You want inline comments to document settings.
  • You're working in Kubernetes, GitHub Actions, or similar tooling.

Verdict

JSON wins for data exchange between machines; YAML wins for configuration humans maintain. YAML's whitespace sensitivity and implicit typing (the famous "Norway problem" where no becomes false) can bite you, so validate it. When in doubt, author in YAML for readability and convert to JSON for processing.

Frequently asked questions

Related free tools