JSON vs YAML

JSON vs YAML: what’s the difference?

Both JSON and YAML are used to represent structured data. JSON is strict and universal; YAML is more human-friendly but easier to get wrong.

Quick comparison

Example: same data

JSON:

{
  "service": "api",
  "port": 8080,
  "enabled": true,
  "tags": ["prod", "us-east-1"]
}

YAML:

service: api
port: 8080
enabled: true
tags:
  - prod
  - us-east-1

Common YAML pitfalls

When to choose JSON

When to choose YAML

Related: Validate JSON · Pretty print JSON