What is the difference between YAML and JSON?


  1. YAML, depending on how you use it, can be more readable than JSON
  2. JSON is often faster and is probably still interoperable with more systems
  3. It’s possible to write a “good enough” JSON parser very quickly
  4. Duplicate keys, which are potentially valid JSON, are definitely invalid YAML.
  5. YAML has a ton of features, including comments and relational anchors. YAML syntax is accordingly quite complex and can be hard to understand.
  6. It is possible to write recursive structures in YAML: {a: &b [*b]}, which will loop infinitely in some converters. Even with circular detection, a “YAML bomb” is still possible (see XML bomb).
  7. Because there are no references, it is impossible to serialize complex structures with object references in JSON. YAML serialization can, therefore, be more efficient.