top of page

YAML vs JSON: Which one is best for what?

  • Writer: Ravi Kant Gupta
    Ravi Kant Gupta
  • Nov 29, 2019
  • 1 min read

YAML over JSON

  • YAML is best suited for defining the configuration whereas JSON is better as a serialization format or serving up data for your APIs

  • YAML is not a replacement for JSON and you should use the data format that makes the most sense for what you are trying to accomplish. YAML has a couple of big advantages over JSON, including the ability to self reference, support for complex data types, embedded block literals, comments, and more

  • Write your configuration files in YAML format where you have the opportunity. YAML is designed to be readable and editable by humans. JSON, in contrast, is only designed to be human readable. JSON intentionally lacking features to support editing. JSON doesn't support comments. This is intentionally left out of the JSON specification because its not what the format was designed for

  • A big win for YAML over JSON is that it does support comments. This is very useful especially when you use it for configuration. For data interchange, many of YAMLs features lose their appeal

  • YAML is a superset of JSON, which means you can parse JSON with a YAML parser

JSON over YAML

  • JSON wins over YAML as a serialization format. It is more explicit and more suitable for data interchange between your apis

  • JSON ships with a far simpler specification than YAML. You can learn JSON a lot faster than you can learn YAML, because it is not nearly as robust in its feature set

Comments


©2019 by RaviKantGupta. Proudly created with Wix.com

bottom of page